1
0
Fork 1
mirror of https://github.com/thatmattlove/hyperglass.git synced 2026-01-30 22:09:21 +00:00
thatmattlove-hyperglass/hyperglass/ui/hooks/useBooleanValue.ts

15 lines
277 B
TypeScript

import { useMemo } from 'react';
export function useBooleanValue<T extends any, F extends any>(
status: boolean,
ifTrue: T,
ifFalse: F,
): T | F {
return useMemo(() => {
if (status) {
return ifTrue;
} else {
return ifFalse;
}
}, [status]);
}