Answers for "this.setState((prevState) => ) using hooks;"

2

prevstate in usestate

const [prevState, setState] = React.useState([]);

setState(prevState => [...prevState, 'somedata'] );
Posted by: Guest on June-09-2020
1

this.setstate prevstate

this.setState(prevState => ({ n: !prevState.n }))
Posted by: Guest on January-25-2021

Code answers related to "this.setState((prevState) => ) using hooks;"

Code answers related to "Javascript"

Browse Popular Code Answers by Language