All Projects → staltz → react-mutant-hoc

staltz / react-mutant-hoc

Licence: MIT license
A utility to make React components easily consume Mutant observables

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

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} />
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].