1.1.0 • Published 6 years ago

react-mutant-hoc v1.1.0

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

react-mutant-hoc

npm install --save react-mutant-hoc

A utility function (higher-order component, 'HOC') that takes a React component as input, and returns a React component that behaves like the input but knows how to observe Mutant observables from props

What problem this package solves

Let's say you have a normal React component that accepts normal props:

<MyComponent isBlue={true} />

But you want the component to accept isBlue as a Mutant observable, and have that component automatically watch the observable and update accordingly.

Usage

import {withMutantProps} from 'react-mutant-hoc';

const MyMutantComponent = withMutantProps(MyComponent, 'isBlue');

// ... then in a render function ...
<MyMutantComponent isBlue={obs} />