@primer/react
Version:
An implementation of GitHub's Primer Design System using React
24 lines (21 loc) • 507 B
JavaScript
import { c } from 'react-compiler-runtime';
import { useContext } from 'react';
import { FeatureFlagContext } from './FeatureFlagContext.js';
/**
* Check if the given feature flag is enabled
*/
function useFeatureFlag(flag) {
const $ = c(3);
const context = useContext(FeatureFlagContext);
let t0;
if ($[0] !== context || $[1] !== flag) {
t0 = context.enabled(flag);
$[0] = context;
$[1] = flag;
$[2] = t0;
} else {
t0 = $[2];
}
return t0;
}
export { useFeatureFlag };