Newer
Older
Matiss Janis Aboltins
committed
import { useSelector } from 'react-redux';
import { type State } from 'loot-core/src/client/state-types';
import type { FeatureFlag } from 'loot-core/src/types/prefs';
const DEFAULT_FEATURE_FLAG_STATE: Record<FeatureFlag, boolean> = {
Jed Fox
committed
reportBudget: false,
goalTemplatesEnabled: false,
iterableTopologicalSort: true,
};
Joel Jeremy Marquez
committed
export function useFeatureFlag(name: FeatureFlag): boolean {
return useSelector((state: State) => {
const value = state.prefs.local[`flags.${name}`];
return value === undefined
? DEFAULT_FEATURE_FLAG_STATE[name] || false
: value;
});