react-reim

import react, {connect, pipeTo} from 'react-reim'

react-reim allows you to use Reim with React.

Exports

react

The plugin for creating HOC from a Reim store.

const store = reim({}).plugin(react())

connect

connect(store: Store, [getter: func, setter: func]) => func => React Element

Connects Reim store to a React component.

const store = reim({name: 'John'})

const User = ({name, changeName})  => (
    <input value={name} onChange={changeName}/>
)

export default connect(
    user,
    // getter
    state => ({name: state.name}),
    // setter
    store => ({
        changeName(ev) {
            store.set({name: ev.target.value})
        }
    })
)(User)

pipeTo

pipeTo(store: Store, [mutation: func]) => React Element

Creates a component that triggers mutation on prop change to Reim store

const store = reim({value: 100})

const Piper = pipeTo(store, (state, props) => {
    state.value += props.count
})

<Piper count={10}/>

Last updated