@cerberus-design/react
Version:
The Cerberus Design React component library.
20 lines (17 loc) • 581 B
JavaScript
'use client';
import { jsx } from 'react/jsx-runtime';
import { createContext, useContext } from 'react';
const FeatureFlagContext = createContext(null);
function FeatureFlags(props) {
return /* @__PURE__ */ jsx(FeatureFlagContext.Provider, { value: props.flags, children: props.children });
}
function useFeatureFlags(key) {
const context = useContext(FeatureFlagContext);
if (context === null) {
throw new Error(
"useFeatureFlag must be used within a FeatureFlags Provider"
);
}
return context[key] ?? false;
}
export { FeatureFlags, useFeatureFlags };