Skip to content

jgbright/react-waterfall

 
 

Repository files navigation

npm version Build Status Coverage Status

react-waterfall

How to use it ?

yarn add react-waterfall

Here is an example of a basic implementation.

import { initStore } from 'react-waterfall'

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

const { Provider, connect } = initStore(store)

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

Count = connect(state => ({ count: state.count }))(Count)

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

You will find more examples here.

Redux DevTools

If you want you can use Redux DevTools with react-waterfall thanks to this middleware.

import { initStore } from 'react-waterfall'
import devtools from 'react-waterfall-redux-devtools-middleware'

const prod = process.env.NODE_ENV === 'production'

export const { Provider, connect } = initStore(store, !prod && devtools())

Types

You can explore types here

Contributors

Links

About

React store built on top of the new context API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%