source dump of claude code
at main 22 lines 703 B view raw
1import React from 'react' 2import { getDynamicConfig_BLOCKS_ON_INIT } from '../services/analytics/growthbook.js' 3 4/** 5 * React hook for dynamic config values. 6 * Returns the default value initially, then updates when the config is fetched. 7 */ 8export function useDynamicConfig<T>(configName: string, defaultValue: T): T { 9 const [configValue, setConfigValue] = React.useState<T>(defaultValue) 10 11 React.useEffect(() => { 12 if (process.env.NODE_ENV === 'test') { 13 // Prevents a test hang when using this hook in tests 14 return 15 } 16 void getDynamicConfig_BLOCKS_ON_INIT<T>(configName, defaultValue).then( 17 setConfigValue, 18 ) 19 }, [configName, defaultValue]) 20 21 return configValue 22}