1.1.0 • Published 4 years ago
react-xstream-hoc v1.1.0
react-xstream-hoc
npm install --save react-xstream-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 listen to xstream streams 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 an xstream stream, and have that component automatically listen to the stream and update accordingly.
Usage
import {withXstreamProps} from 'react-xstream-hoc';
const MyXSComponent = withXstreamProps(MyComponent, 'isBlue');
// ... then in a render function ...
<MyXSComponent isBlue={obs} />