Skip to content

A simple HOC that allows you to toggle the visibility of a wrapped component by typing a custom konami code.

License

Notifications You must be signed in to change notification settings

brodeynewman/react-beta-component

Repository files navigation

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

Prop Default required Description
keyCode Yes The key code to enable your component.
keyCodeTimeout 500 No If your code isn't typed within this amount of time (in ms), you will have to restart.
forceEnable false No If you want to always render this component. If keyCode is typed while this flag is passed, it will still toggle your component.

About

A simple HOC that allows you to toggle the visibility of a wrapped component by typing a custom konami code.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published