mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
15 lines
557 B
TypeScript
15 lines
557 B
TypeScript
import type { WidenPrimitives } from '@growthbook/growthbook';
|
|
import { useFeatureValue, useGrowthBook } from '@growthbook/growthbook-react';
|
|
|
|
import type { GrowthBookFeatures } from './init';
|
|
|
|
export default function useGbFeatureValue<Name extends keyof GrowthBookFeatures>(
|
|
name: Name,
|
|
fallback: GrowthBookFeatures[Name],
|
|
): { value: WidenPrimitives<GrowthBookFeatures[Name]>; isLoading: boolean } {
|
|
const value = useFeatureValue(name, fallback);
|
|
const growthBook = useGrowthBook();
|
|
|
|
return { value, isLoading: !(growthBook?.ready ?? true) };
|
|
}
|