2.0.1 • Published 8 years ago
react-feature v2.0.1
react-feature

Setup
npm install react-feature --saveor
yarn add react-featureand then
import { Feature } from 'react-feature'Basic usage
Render feature depending on provided feature config:
<Feature name='banner:head' config={{'banner:head': true, 'feature2': true}}>
<strong>Some html related to the feature</strong>
</Feature>If you want to render an alternative case for the feature, when the feature is not present, you can use a negation sign within the name:
<Feature name='!banner:head' config={{feature1: true, feature2: true}}>
<i>Some alternative html for the feature</i>
</Feature>Usage with Redux
If you want to provide config for <Feature> component from Redux store, simply
create <FeatureContainer> and connect proper state to config prop:
import { connect } from 'react-redux'
import { Feature } from 'react-feature'
const mapStateToProps = (state) => {
return {
config: state.featuresConfig
}
}
const mapDispatchToProps = (dispatch, ownProps) => {
return {
}
}
const FeatureContainer = connect(
mapStateToProps,
mapDispatchToProps
)(Feature)
export default FeatureContainerand then use <FeatureContainer> instead:
<FeatureContainer name='banner:head'>
<strong>Some html related to the feature</strong>
</FeatureContainer>Usage with config file
import { Feature } from 'react-feature'
import config from './config'
const FeatureContainer = ({name, children}) => (
<Feature name={name} config={config}>
{children}
</Feature>
)
export default FeatureContainer2.0.1
8 years ago
2.0.0
8 years ago
1.0.3
8 years ago
1.0.2
8 years ago
1.0.1
9 years ago
1.0.0
9 years ago
1.0.0-alpha.2
9 years ago
1.0.0-alpha.1
9 years ago
1.0.0-alpha.0
9 years ago