Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(previousFlags, [flagName, flagVariation]: [FlagName, FlagVariation]) => {
const isFeatureEnabled: boolean = getIsFeatureEnabled(
flagName,
flagVariation
)(allFlags);
return [...previousFlags, isFeatureEnabled];
},
[]
withProps(props => ({
isFeatureEnabled: getIsFeatureEnabled(
props.flag,
props.variation
)(props[ALL_FLAGS_PROP_KEY]),
}))
)(ToggleFeature);
export default function useFeatureToggle(
flagName: FlagName,
flagVariation: FlagVariation = true
): boolean {
const flags: Flags = React.useContext(FlagsContext);
const isFeatureEnabled: boolean = getIsFeatureEnabled(
flagName,
flagVariation
)(flags);
React.useDebugValue({
flagName,
flagVariation,
isEnabled: isFeatureEnabled,
});
return isFeatureEnabled;
}
export const mapStateToProps = (state: State, ownProps: OwnProps): object => ({
isFeatureEnabled: getIsFeatureEnabled(
ownProps.flag,
ownProps.variation
)(state[STATE_SLICE].flags ?? {}),
});