mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-04-25 11:59:11 +00:00
20 lines
466 B
TypeScript
20 lines
466 B
TypeScript
import {
|
|
FeatureFlag,
|
|
FeatureFlagsContext,
|
|
} from '@roleypoly/misc-utils/featureFlags/react';
|
|
import * as React from 'react';
|
|
|
|
export type FeatureGateProps = {
|
|
featureFlag: FeatureFlag;
|
|
children: () => React.ReactNode;
|
|
};
|
|
|
|
export const FeatureGate = (props: FeatureGateProps) => {
|
|
const featureContext = React.useContext(FeatureFlagsContext);
|
|
|
|
if (featureContext.has(props.featureFlag)) {
|
|
return props.children();
|
|
} else {
|
|
return <></>;
|
|
}
|
|
};
|