Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(react): use
updater
callback function
callback takes the previous state as the first argument. > setState() does not always immediately update the component. It may batch or defer the update until later. This makes reading this.state right after calling setState() a potential pitfall. Instead, use componentDidUpdate or a setState callback (setState(updater, callback)), either of which are guaranteed to fire after the update has been applied. If you need to set the state based on the previous state, read about the updater argument below. see: - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-access-state-in-setstate.md - https://reactjs.org/docs/react-component.html#setstate
- Loading branch information