Answers for "react array usestate"

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
1

usestate array

setTheArray(oldArray => [...oldArray, newElement]);
Posted by: Guest on October-20-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language