previstate no uso
const [prevState, setState] = React.useState([]);
setState(prevState => [...prevState, 'somedata'] );
Salo Hopeless
const [prevState, setState] = React.useState([]);
setState(prevState => [...prevState, 'somedata'] );
handleClick() {
this.setState(prevState => {
return {
count: prevState.count + 1
}
})
}
this.setState(prevState => ({ n: !prevState.n }))