Reim
Github
2.0.0
2.0.0
  • Reim.js
  • Introduction
    • Motivation
    • Concepts
  • Guide
    • Store
    • setState
    • Subscribe
    • Plugin
    • Event Emitter
    • Use with React / Preact
    • Use with Vue
    • Use with Angular / Rxjs
  • Ecosystem
    • react-reim
    • reim-task
    • reim-reporter
    • reim-persist
    • Release Notes
Powered by GitBook
On this page
  • Exports
  • react
  • connect
  • pipeTo
  1. Ecosystem

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}/>
PreviousUse with Angular / RxjsNextreim-task

Last updated 6 years ago