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