React bindings for opstore.
npm install react-opstoreDISCLAIMER:
react-opstoreis inspired byreact-redux.
import {connect, Provider} from 'react-opstore'
import {createStore} from 'opstore'
import React from 'react'
import {render} from 'react-dom'
const Counter = ({count}) => (
<div className="counter">
<button onClick={count.decr}>-</button>
<span>{count.get()}</span>
<button onClick={count.incr}>+</button>
</div>
)
const mapStoreToProps = store => ({
count: store.ref('count')
})
const ConnectedCounter = connect(mapStoreToProps)(Counter)
const store = createStore({count: 0})
render(
<Provider store={store}>
<ConnectedCounter />
</Provider>,
document.body
)MIT © Marius Lundgård