New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@blacklane/react-feature

Package Overview
Dependencies
Maintainers
2
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blacklane/react-feature

Simple feature flip mechanism for React

2.1.0
latest
Source
npm
Version published
Maintainers
2
Created
Source

react-feature Build Status npm version

Setup

npm install react-feature --save

or

yarn add react-feature

and then

import { Feature } from "react-feature";

Basic usage

Render feature depending on provided feature config:

<Feature name="banner:head" config={{ "banner:head": true, feature2: true }}>
  <strong>Some html related to the feature</strong>
</Feature>

If you want to render an alternative case for the feature, when the feature is not present, you can use a negation sign within the name:

<Feature name="!banner:head" config={{ feature1: true, feature2: true }}>
  <i>Some alternative html for the feature</i>
</Feature>

Usage with Redux

If you want to provide config for <Feature> component from Redux store, simply create <FeatureContainer> and connect proper state to config prop:

import { connect } from "react-redux";
import { Feature } from "react-feature";

const mapStateToProps = state => {
  return {
    config: state.featuresConfig
  };
};

const mapDispatchToProps = (dispatch, ownProps) => {
  return {};
};

const FeatureContainer = connect(
  mapStateToProps,
  mapDispatchToProps
)(Feature);

export default FeatureContainer;

and then use <FeatureContainer> instead:

<FeatureContainer name="banner:head">
  <strong>Some html related to the feature</strong>
</FeatureContainer>

Usage with config file

import { Feature } from "react-feature";
import config from "./config";

const FeatureContainer = ({ name, children }) => (
  <Feature name={name} config={config}>
    {children}
  </Feature>
);

export default FeatureContainer;

Keywords

react

FAQs

Package last updated on 20 Sep 2018

Did you know?

Socket

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.

Install

Related posts