Feature flagging React component with Redux store
npm install react-redux-feature-flagsThis package works with React and Redux to provide an easy-to-use feature wrapping component.
Using npm:
```
$ npm install --save react-redux-feature-flags
To utilize the featureFlagsReducer, you must first import it into your project and combine with your other project reducers using Redux's combineReducers method:
`js
import { combineReducers } from 'redux';
import { featureFlagsReducer } from 'react-redux-feature-flags';
import otherReducer from './otherReducer';
const rootReducer = combineReducers({
otherReducer,
features: featureFlagsReducer,
});
export default rootReducer;
`
file in the root directory of your project:`js
const features = {
someFeature: true,
someOtherFeature: false
} export default features;
`You can then import your features into to your
index.js file (example using ES6) and pass them to the dispatchable addFeatureFlags method:`js
import { addFeatureFlags } from 'react-redux-feature-flags'; import features from './features';
/*
* Initialize Feature Flags
**/
store.dispatch(addFeatureFlags(features));
`$3
Finally, you can wrap your feature in the
Feature component and pass it a flag defined in your features.js. If the flag is truthy, the children of the Feature component will render:`jsx
``