1.7.0 • Published 3 years ago

feature-flags-reactjs v1.7.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

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-reactjs

Using yarn:

yarn add feature-flags-reactjs

2. 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();