MCPcopy Create free account
hub / github.com/freecodexyz/free-code / useDynamicConfig

Function useDynamicConfig

src/hooks/useDynamicConfig.ts:8–22  ·  view source on GitHub ↗
(configName: string, defaultValue: T)

Source from the content-addressed store, hash-verified

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}

Callers 1

useFeedbackSurveyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected