MCPcopy Index your code
hub / github.com/RosyTucker/react-feature-toggles

github.com/RosyTucker/react-feature-toggles @3.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 3.0.0 ↗ · + Follow
9 symbols 22 edges 8 files 0 documented · 0% updated 8y ago3.0.0 · 2018-02-03★ 442 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

react-feature-toggles

Declarative feature toggle framework for react / react-native, allowing you to get rid of test complications, and branching logic.

Build Status

npm version

Install

npm install --save react-feature-toggles

Usage

Wrap your app in the FeatureToggleProvider and pass in a list of toggles, then use the FeatureToggle component throughout your application.

Both FeatureToggleProvider and FeatureToggle must have only one child, this is so that the library isn't rendering additional elements on your behalf and making assumptions about your needs e.g you may want an <li> rather than a `

`.

import React from 'react';
import ReactDOM from 'react-dom';
import { FeatureToggleProvider, FeatureToggle } from 'react-feature-toggles';

const toggles = {
  // Try setting this to true
  SHOW_HELLO_WORLD: false
  // ... add more here
};

const ExampleApp = () => (
  <FeatureToggleProvider featureToggleList={toggles}>



      <h1>Toggling Example</h1>
      <FeatureToggle featureName={toggleNames.SHOW_HELLO_WORLD}>


Hello World


      </FeatureToggle>
      <FeatureToggle featureName={toggleNames.SHOW_HELLO_WORLD} showOnlyWhenDisabled>


Sorry, toggle is off


      </FeatureToggle>



  </FeatureToggleProvider>
);


ReactDOM.render(<ExampleApp />, document.getElementById('example'));

Redux

To use with redux you may want to do something like:

const mapStateToProps = state => ({
  featureToggleList: state.features,
});

const ConnectedFeatureToggleProvider = connect(mapStateToProps)(FeatureToggleProvider);

And then use the connected provider in place of the normal provider.

Building the example

  • Clone this repo
  • Run npm install
  • Run npm run build-example
  • Open example/example.html in the browser
  • Play around with the toggle values

Making a pull request?

  • Make sure you've run npm run ci-build first

Changes

  • Version 2.0.3 Switch proptypes from React.PropTypes to the dedicated proptypes library
  • Version 2.0.2 unsures an undefined toggle is treated a false
  • Version 2.0.1 removes a containing div around the provider children, should you need this div, please add it in yourself.

Core symbols most depended-on inside this repo

Shape

Class 4
Method 3
Function 2

Languages

TypeScript100%

Modules by API surface

src/FeatureToggleProvider.jsx4 symbols
src/FeatureToggle.jsx3 symbols
webpack.example.config.babel.js1 symbols
example/example.jsx1 symbols

For agents

$ claude mcp add react-feature-toggles \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page