Answers for "setstate list react hooks"

5

React Hooks append state

setTheArray(currentArray => [...currentArray, newElement])
Posted by: Guest on November-07-2020
2

prevstate in usestate

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

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

Code answers related to "setstate list react hooks"

Code answers related to "Javascript"

Browse Popular Code Answers by Language