Skip to content
600 byte state management for React.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
Connect.js
Context.js
Provider.js
README.md
index.js
package-lock.json
package.json

README.md

@picostate/react

600 byte state management for React using picostate.

v2 brings support for React 16's context API

Install

npm i @picostate/react --save

Usage

import createStore from 'picostate'
import { Provider, connect } from '@picostate/react'

const store = createStore({
  count: 0
})

const Counter = connect((state, props) => ({
  count: state.count
}))(props => (
  <div>
    <h1>The count is {props.count}</h1>

    <button onClick={e => {
      props.hydrate(state => ({
        count: state.count + 1
      }))()
    }}>Increment</button>
  </div>
))

render((
  <Provider store={store}>
    <Counter />
  </Provider>
), document.body)

license

MIT License © Eric Bailey

You can’t perform that action at this time.