setstate hooks prevstate code example
Example 1: prevstate in usestate
const [prevState, setState] = React.useState([]);
setState(prevState => [...prevState, 'somedata'] );
Example 2: this.setstate prevstate
this.setState(prevState => ({ n: !prevState.n }))