1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/frontend/src/hooks/useVariant.ts

11 lines
300 B
TypeScript
Raw Normal View History

import { useMemo } from 'react';
import { type Variant, getVariantValue } from 'utils/variants';
export const useVariant = <T = string>(variant?: Variant) => {
return useMemo(() => {
if (variant?.enabled) {
return getVariantValue<T>(variant);
}
}, [variant]);
};