React store built on top of the new context API
const Count = connect(({ count }) => ({ count }))(({ count }) => count)
class App extends Component {
componentDidMount() {
actions.increment()
actions.increment()
// <Count /> will display `2`
}
render() {
return (
<Provider>
<Count />
</Provider>
)
}
}
Watch it there
Basic example
getMovies: async (_, actions, load) => {
if (!load) await actions.getMovies(true)
else return { movies: { loading: true } }
const data = await fetchMovies()
return { movies: { loading: false, data } }
}
→ You'll find this example in context here
<button
onClick={async () => {
await actions.doSomething();
actions.doSomethingElse();
}}
>
+
</button>
<Provider initialState={state}>
<App />
</Provider>
unsubscribe
causing a kind of memory leak https://github.com/didierfranc/react-waterfall/pull/44 @hansoksendahlWhat it was just a tutorial for the new context API has become a simple store for #ReactJS used in real life.