how to setstate in react with prevstate code example Example: this.setstate prevstate this.setState(prevState => ({ n: !prevState.n }))