mirror of https://github.com/jetkvm/kvm.git
16 lines
467 B
TypeScript
16 lines
467 B
TypeScript
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 };
|
|
};
|