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