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)

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.2
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.2
    0
  • 0.1.1
    1
  • 0.1.0
    1

Package Sidebar

Install

npm i rxsc-react

Weekly Downloads

2

Version

0.1.2

License

MIT

Last publish

Collaborators

  • lohmander