useFeatureFlag Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import useFeatureFlag from './useFeatureFlag'; | |
import RecommendationsComponent from './Recommendations.js'; | |
const { | |
DecoratedComponent: Recommendations, | |
featureEnabled: recommendationsFeatureEnabled, | |
FeatureFlag | |
} = useFeatureFlag({ | |
Component: RecommendationsComponent, | |
feature: 'RECOMMENDATIONS' | |
}); | |
const ExampleComponent = () => { | |
const pageTitle = recommendationsFeatureEnabled ? 'Recommendations' : 'Saved Items'; | |
return <div> | |
<h1>{pageTitle}</h1> | |
<Recommendations /> | |
<FeatureFlag> | |
<Dependency recommendations={recommendations} /> | |
</FeatureFlag> | |
</div>; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
const Recommendations = ({ featureEnabled }) => { | |
if (!featureEnabled) { | |
return <div>Page Not Found</div> | |
} | |
return <div> | |
<h1>Recommendations</h1> | |
<div>{recommendations}</div> | |
</div>; | |
} | |
export default Recommendations; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment