Skip to content

Commit 6e48790

Browse files
neaumusicstefanwullems
authored and
stefanwullems
committed
[Docs] no-access-state-in-setstate: update grammar
1 parent 5793376 commit 6e48790

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docs/rules/no-access-state-in-setstate.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ function increment() {
1111
}
1212
```
1313

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:
14+
If two `setState` operations are grouped together in a batch, they
15+
both evaluate the old state. Given that `state.value` is 1:
1616

1717
```javascript
18-
setState({value: 1 + 1})
19-
setState({value: 1 + 1})
18+
setState({value: this.state.value + 1}) // 2
19+
setState({value: this.state.value + 1}) // 2, not 3
2020
```
2121

2222
This can be avoided with using callbacks which takes the previous state

0 commit comments

Comments
 (0)