0.3.0 • Published 5 years ago

react-beta-component v0.3.0

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

react-beta-component

A tiny higher order component that enables you to toggle the rendering of a wrapped component based on a custom konami-like code.

Demo

Try it out!

Edit 98yzx39wwp

Why?

Maybe you need a feature to be in production but behind some type of beta flag?

Or, you just think it's cool to have a feature only accessable by some type of key code.

Installation

npm install --save react-beta-component

Usage

import React from 'react';
import withBetaComponent from 'react-beta-component';

const TestComponent = (props) => (
  <div>
    Test component!
  </div>
);

export default withBetaComponent({
  keyCode: '**foo**',
  keyCodeTimeout: 1000,
})(TestComponent);

Simply wrap your feature in the withBetaComponent HOC and supply the keyCode.

Options

PropDefaultrequiredDescription
keyCodeYesThe key code to enable your component.
keyCodeTimeout500NoIf your code isn't typed within this amount of time (in ms), you will have to restart.
forceEnablefalseNoIf you want to always render this component. If keyCode is typed while this flag is passed, it will still toggle your component.
0.3.0

5 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago