prevstate == this.state code example
Example 1: react prevstate
handleClick() {
this.setState(prevState => ({
isToggleOn: !prevState.isToggleOn
}));
}
Example 2: this.setstate prevstate
this.setState(prevState => ({ n: !prevState.n }))
handleClick() {
this.setState(prevState => ({
isToggleOn: !prevState.isToggleOn
}));
}
this.setState(prevState => ({ n: !prevState.n }))