2.0.4 • Published 6 years ago
react-opstore v2.0.4
react-opstore
React bindings for opstore
.
npm install react-opstore
DISCLAIMER:
react-opstore
is inspired byreact-redux
.
Usage
import {connect, Provider} from 'react-opstore'
import {createStore} from 'opstore'
import React, {Component} from 'react'
import {render} from 'react-dom'
class App extends Component {
render() {
const {count} = this.props
return (
<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 ConnectedApp = connect(mapStoreToProps)(App)
const store = createStore({count: 0})
render(
<Provider store={store}>
<ConnectedApp />
</Provider>,
document.body
)
License
MIT © Marius Lundgård