Netherworld's Pretend Minibar
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

rxsc-react

0.1.2 • Public • Published

RxSC-React

This library provides a simple function to connect a React components state to the RxSC state container.

Installation

With npm

$ npm install --save rxcs-react

With yarn

$ yarn add rxcs-react

Usage

import React, { Component } from 'react';
import { connect } from 'rxsc-react';
 
import container from './myContainer';
 
 
class MyComponent extends Component {
 
    render() {
        let { count, actions$ } = this.props;
 
        return (
            <div>
                <div>{count}</div>
                <button onClick={() => actions$.increment(1)}>+</button>
                <button onClick={() => actions$.decrement(1)}>-</button>
            </div>
        );
    }
}
 
export default connect(container)(MyComponent);

You can also pass a second argument to connect with a mapping function which will further reduce the state before it is passed to the component.

// ...
 
export default connect(
    container,
    state => ({ ...state, double: state.count * 2 })
)(MyComponent)

Keywords

none

install

npm i rxsc-react

Downloadsweekly downloads

3

version

0.1.2

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar