Skip to content

Commit cadee91

Browse files
杨俊宁ljharb
authored andcommitted
[Docs] no-access-state-in-setstate: fix example
1 parent e8d2ce9 commit cadee91

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ If two `setState` operations are grouped together in a batch, they
1515
both evaluate the old state. Given that `state.value` is 1:
1616

1717
```javascript
18-
setState({value: this.state.value + 1}) // 2
19-
setState({value: this.state.value + 1}) // 2, not 3
18+
this.setState({value: this.state.value + 1}) // 2
19+
this.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)