prev state in this.setstate code example
Example 1: this.setstate prevstate
this.setState(prevState => ({ n: !prevState.n }))
Example 2: prevstate in react
handleClick() {
this.setState(prevState => {
return {
count: prevState.count + 1
}
})
}