Skip to content

Latest commit

 

History

History

carry-on-react

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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>
);