This commit is contained in:
HugeFrog24
2026-04-25 14:00:45 +02:00
parent 4f2d4c4a59
commit 33af88d79d
68 changed files with 8587 additions and 6868 deletions
+27
View File
@@ -0,0 +1,27 @@
'use client';
import { createContext, useContext } from 'react';
import type { FeatureFlags } from '../config/features';
const FeatureContext = createContext<FeatureFlags | undefined>(undefined);
interface FeatureProviderProps {
features: FeatureFlags;
children: React.ReactNode;
}
export function FeatureProvider({ features, children }: FeatureProviderProps) {
return (
<FeatureContext.Provider value={features}>
{children}
</FeatureContext.Provider>
);
}
export function useFeature<K extends keyof FeatureFlags>(key: K): FeatureFlags[K] {
const context = useContext(FeatureContext);
if (context === undefined) {
throw new Error('useFeature must be used within a FeatureProvider');
}
return context[key];
}