Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import flowRight from 'lodash/flowRight';
import {
ToggleFeature,
getIsFeatureEnabled,
setDisplayName,
withProps,
ALL_FLAGS_PROP_KEY,
} from '@flopflip/react';
import { withFlags } from '../configure';
export default flowRight(
setDisplayName(ToggleFeature.displayName),
withFlags(),
withProps(props => ({
isFeatureEnabled: getIsFeatureEnabled(
props.flag,
props.variation
)(props[ALL_FLAGS_PROP_KEY]),
}))
)(ToggleFeature);
import { STATE_SLICE } from './../../store/constants';
type OwnProps = {
flag: FlagName;
variation: FlagVariation;
};
export const mapStateToProps = (state: State, ownProps: OwnProps): object => ({
isFeatureEnabled: getIsFeatureEnabled(
ownProps.flag,
ownProps.variation
)(state[STATE_SLICE].flags ?? {}),
});
export default flowRight(
setDisplayName(ToggleFeature.displayName),
connect(mapStateToProps)
)(ToggleFeature);