From 8834348abf9ea7339d308bda6cf45f2e785a4f8d Mon Sep 17 00:00:00 2001 From: Boaz Berman Date: Sat, 16 Jun 2018 20:11:54 +0300 Subject: [PATCH] Fix broken example in the README.md In the example store.setState was called with what could be a stale state. In order to use the current state, one must call store.getState. Similar to how in React if you call setState without a callback it is a potential bug. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1ddf7f5..b8fb90c 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ let actions = store => ({ // ... or just actions that call store.setState() later: incrementAsync(state) { setTimeout( () => { - store.setState({ count: state.count+1 }) + store.setState({ count: store.getState().count+1 }) }, 100) } })