react setstate prevstate add into array example Example: this.setstate prevstate this.setState(prevState => ({ n: !prevState.n }))