staltz / react-xstream-hoc

A utility to make React components easily consume xstream streams

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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} />

About

A utility to make React components easily consume xstream streams

License:MIT License


Languages

Language:JavaScript 59.7%Language:TypeScript 40.3%