carry-on-react

2.0.0-alpha.5 • Public • Published

carry-on-react

State container for React. Requires Proxy.

Read the documentation at: https://dfadev.github.io/carry-on

Features

  • Mutate state directly
  • No selector necessary
  • Batch update only changed components
  • Multiple stores
  • State component or withState higher order component
  • Middleware
  • Optional form handling: carry-on-react-forms
  • Flexible State properties: debounce, throttle, constant, strict, select, path, from

Install

npm install --save carry-on-react

Import

import { State, register } from "carry-on-react";

Simple store

register({
  state: ({ set }) => ({
    counter: 0,
    inc: () => set(state => { state.counter++; }),
    dec: () => set(state => { state.counter--; })
  })
});

const App = () => (
  <State>
    {state => (
      <div>
        <div>Counter: {state.counter}</div>
        <button onClick={state.inc}>+</button>
        <button onClick={state.dec}>-</button>
      </div>
    )}
  </State>
);

Readme

Keywords

none

Package Sidebar

Install

npm i carry-on-react

Weekly Downloads

2

Version

2.0.0-alpha.5

License

MIT

Unpacked Size

272 kB

Total Files

33

Last publish

Collaborators

  • dfadev