Simple feature toggles for react and react router
npm install react-awesome-feature-toggles



---
This plugin provides a feature toggle component
- Set feature config and check if a toggle is enabled
- Use FeatureToggle Component to render children if a toggle is enabled
- Use FeatureToggle Component to render sub-routes if a toggle is enabled
Install react-awesome-feature-toggles using npm:
npm install --save react-awesome-feature-toggles
Use setFeatureConfig to set you config. It accepts an object with keys which will be used as the names of your features. It currently does not (yet) support nested objects
``Javascript
import { setFeatureConfig } from 'react-awesome-feature-toggles'
setFeatureConfig({
"awesome.feature": true,
"disabled.feature": false
})
`
Now use the Component to conditionally render children
`Javascript
import { FeatureToggle } from 'react-awesome-feature-toggles'
return (
You can also use
to enable routes conditionally. The disabled routes are taken from the route structure just like as if they do not exist:`Javascript
import { Route, IndexRoute, match } from 'react-router'
import { FeatureToggle } from 'react-awesome-feature-toggles' const routes = (
)
`This would lead to a router that matches
/route1 but not /route2`.MIT