/react-waterfall

React store built on top of the new context API

Primary LanguageJavaScriptMIT LicenseMIT

react-waterfall

How to use it ?

yarn add react-waterfall

Here is an example of the simplest implementation.

import { initStore } from 'react-waterfall'

const store = {
  initialState: { count: 0 },
  actions: {
    increment: ({ count }) => ({ count: count + 1 }),
  },
}

const { Provider, connect } = initStore(store)

let Count = ({ state, actions }) => (
  <>
    {state.count}
    <button onClick={actions.increment}>+</button>
  </>
)

Count = connect(['count'])(Count)

const App = () => (
  <Provider>
    <Count />
  </Provider>
)

Types

You can explore types here

Advanced

Advanced examples are available here

screenshot

Links