import { createContext, ReactNode, useEffect, useState } from 'react' interface FeatureToggleContextType { experimentalFeatureEnabed: boolean setExperimentalFeatureEnabled: (on: boolean) => void } const initialContext: FeatureToggleContextType = { experimentalFeatureEnabed: false, setExperimentalFeatureEnabled: () => {}, } export const FeatureToggleContext = createContext(initialContext) export default function FeatureToggleWrapper({ children, }: { children: ReactNode }) { const EXPERIMENTAL_FEATURE_ENABLED = 'expermientalFeatureEnabled' const [experimentalEnabed, setExperimentalEnabled] = useState(false) useEffect(() => { // Global experimental feature is disabled let globalFeatureEnabled = false if (localStorage.getItem(EXPERIMENTAL_FEATURE_ENABLED) !== 'true') { // eslint-disable-next-line @typescript-eslint/no-unused-vars globalFeatureEnabled = true } }, []) const setExperimentalFeature = (on: boolean) => { localStorage.setItem(EXPERIMENTAL_FEATURE_ENABLED, on ? 'true' : 'false') setExperimentalEnabled(on) } return ( {children} ) }