falx-react

1.0.1 • Public • Published

falx-react

falx HOC for react

installation

npm i -S falx-redux

usage

import React, {PureComponent} from 'react'
import {subscribeHOC} from 'falx-react'
import {register} from 'falx'


const reducer = {
    state: {
        value: 0
    },
    actions: {
        up(state) {
            return {
                ...state,
                value: state.value + 1
            }
        },
        down(state) {
            return {
                ...state,
                value: state.value - 1
            }
        }
    }
};

const COUNTER = 'counter';

register(COUNTER, reducer);

@subscribeHOC(COUNTER)
class Counter extends PureComponent {
    render() {
        return (
            <div>
                <div id="value">
                    {this.props.counter.value}
                </div>
                <button id="up" onClick={this.props.up} >up</button>
                <button id="down" onClick={this.props.down} >down</button>
            </div>
        )
    }
}

Readme

Keywords

Package Sidebar

Install

npm i falx-react

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

120 kB

Total Files

26

Last publish

Collaborators

  • one-more