mirror of
https://github.com/luckfox-eng29/kvm.git
synced 2026-05-28 00:51:22 +02:00
feat(ui): Add feature flag system (#208)
This commit is contained in:
15
ui/src/hooks/useFeatureFlag.ts
Normal file
15
ui/src/hooks/useFeatureFlag.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { useContext } from "react";
|
||||
import { FeatureFlagContext } from "../providers/FeatureFlagProvider";
|
||||
|
||||
export const useFeatureFlag = (minAppVersion: string) => {
|
||||
const context = useContext(FeatureFlagContext);
|
||||
|
||||
if (!context) {
|
||||
throw new Error("useFeatureFlag must be used within a FeatureFlagProvider");
|
||||
}
|
||||
|
||||
const { isFeatureEnabled, appVersion } = context;
|
||||
|
||||
const isEnabled = isFeatureEnabled(minAppVersion);
|
||||
return { isEnabled, appVersion };
|
||||
};
|
||||
Reference in New Issue
Block a user