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

update grammar for no-access-state-in-setstate.md #2418

Merged
merged 1 commit into from
Oct 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/rules/no-access-state-in-setstate.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ function increment() {
}
```

If these two `setState` operations is grouped together in a batch it will
look be something like the following, given that value is 1:
If two `setState` operations are grouped together in a batch, they
ljharb marked this conversation as resolved.
Show resolved Hide resolved
both evaluate the old state. Given that `state.value` is 1:

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

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