Package Exports
- feature-flags-reactjs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (feature-flags-reactjs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Feature Flags for ReactJS
Consume the Feature Flags API from Assertiva using this library in ReactJS Projects.
How use
1. Install as dependencies in your project
Using npm:
npm install feature-flags-reactjsUsing yarn:
yarn add feature-flags-reactjs2. Declare a provider in your main script (app.js or app.ts)
import FeatureFlagsProvider from 'feature-flags-reactjs/FeatureFlagsProvider';
const App = () => {
return (
<FeatureFlagsProvider
//required prop
url="http://localhost:5000"
//required prop
product="ProductName"
>
<HomePage />
</FeatureFlagsProvider>
)
}
export default App();
3. In your component use FeatureFlags tag and use onAvailable to success or onUnavailable to error:
import FeatureFlags from 'feature-flags-reactjs/FeatureFlags';
const HomePage = () => {
return (
<FeatureFlags
//required prop
flag="FlagName"
//optional prop
canUse={[]}
// required prop
onAvailable={
<h1>
FlagName is on
</h1>
}
//required prop
onUnavailable={
<h1>
FlagName is off
</h1>
}
/>
)
}
export default HomePage();