Skip to content

Instantly share code, notes, and snippets.

@jordangarcia
Created November 14, 2018 00:04
Show Gist options
  • Save jordangarcia/dde7060c4a18307e74fcceca6c6445f9 to your computer and use it in GitHub Desktop.
Save jordangarcia/dde7060c4a18307e74fcceca6c6445f9 to your computer and use it in GitHub Desktop.
const myFeature = createFeatureInstance('my-feature', {
getComponent(isEnabled, variables) {
return isEnabled
? ExtendedComponent
: StandardComponent
},
fetchData(isEnabled, variables) {
return isEnabled
? getExtendedData()
: getStandardData()
},
})
// in routing
myFeature.fetchData()
// in component
render() {
const MyFeatureComponent = myFeature.getComponent()
return (
<MyFeatureComponent {...propsToPass} />
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment