Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs] no-access-state-in-setstate: fix example #2724

Merged
merged 1 commit into from Jul 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/rules/no-access-state-in-setstate.md
Expand Up @@ -15,8 +15,8 @@ If two `setState` operations are grouped together in a batch, they
both evaluate the old state. Given that `state.value` is 1:

```javascript
setState({value: this.state.value + 1}) // 2
setState({value: this.state.value + 1}) // 2, not 3
this.setState({value: this.state.value + 1}) // 2
this.setState({value: this.state.value + 1}) // 2, not 3
```

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