We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
no-access-state-in-setstate
1 parent 4a05fa2 commit 3124ce0Copy full SHA for 3124ce0
docs/rules/no-access-state-in-setstate.md
@@ -11,12 +11,12 @@ function increment() {
11
}
12
```
13
14
-If these two `setState` operations is grouped together in a batch it will
15
-look be something like the following, given that value is 1:
+If two `setState` operations are grouped together in a batch, they
+both evaluate the old state. Given that `state.value` is 1:
16
17
```javascript
18
-setState({value: 1 + 1})
19
+setState({value: this.state.value + 1}) // 2
+setState({value: this.state.value + 1}) // 2, not 3
20
21
22
This can be avoided with using callbacks which takes the previous state
0 commit comments