
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
react-feature-toggles
Advanced tools
Feature toggle framework for react - down with feature branches
Declarative feature toggle framework for react / react-native, allowing you to get rid of test complications, and branching logic.
npm install --save react-feature-toggles
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 <div>
.
import React from 'react';
import ReactDOM from 'react-dom';
import { FeatureToggleProvider, FeatureToggle } from '../lib/index';
const toggleNames = {
SHOW_HELLO_WORLD: 'showHelloWorld'
// ... add more here
};
const toggles = {
// Try setting this to true
[toggleNames.SHOW_HELLO_WORLD]: false
// ... add more here
};
const ExampleComponent = () => (
<FeatureToggleProvider featureToggleList={toggles}>
<div>
<h1>Toggling Example</h1>
<FeatureToggle featureName={toggleNames.SHOW_HELLO_WORLD}>
<p>Hello World</p>
</FeatureToggle>
<FeatureToggle featureName={toggleNames.SHOW_HELLO_WORLD} showOnlyWhenDisabled>
<p>Sorry, toggle is off</p>
</FeatureToggle>
</div>
</FeatureToggleProvider>
);
ReactDOM.render(<ExampleComponent />, document.getElementById('example'));
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.
npm install
npm run build-example
example/example.html
in the browsernpm run ci-build
firstFAQs
Feature toggle framework for react - down with feature branches
The npm package react-feature-toggles receives a total of 555 weekly downloads. As such, react-feature-toggles popularity was classified as not popular.
We found that react-feature-toggles demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.