12 ms·
If you’re saying that `this.state` doesn’t update immediately after `this.setState` so you can‘t use the previous value, one way to get around this is to use `t
by danabramov 11y ago
If you’re saying that `this.state` doesn’t update immediately after `this.setState` so you can‘t use the previous value, one way to get around this is to use `this.setState` overload that takes a function:
this.setState(prevState => ({ prevState.count + 1 }))
This way all the changes will be stacked on top of each other correctly.