mariuslundgard / react-opstore

React bindings for opstore.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

react-opstore

React bindings for opstore.

npm install react-opstore

build status coverage status npm version

DISCLAIMER: react-opstore is inspired by react-redux.

Usage

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
)

License

MIT © Marius Lundgård

About

React bindings for opstore.

License:MIT License


Languages

Language:TypeScript 97.7%Language:JavaScript 2.3%