UNPKG

@devcycle/nextjs-sdk

Version:

The Next.js SDK for DevCycle!

18 lines 766 B
'use client'; import { useContext, use } from 'react'; import { DevCycleProviderContext } from './internal/context'; import { useRerenderOnVariableChange } from './internal/useRerenderOnVariableChange'; export const useVariable = (key, defaultValue) => { const context = useContext(DevCycleProviderContext); useRerenderOnVariableChange(key); // Fall back to nearest suspense boundary if client is not initialized yet. if (context.enableStreaming) { use(context.client.onClientInitialized()); } return context.client.variable(key, defaultValue); }; export const useVariableValue = (key, defaultValue) => { return useVariable(key, defaultValue).value; }; export default useVariableValue; //# sourceMappingURL=useVariableValue.js.map