react js usestate spread array code example
Example 1: usestate array push
setTheArray([...theArray, newElement]);
Example 2: prevstate in usestate
const [prevState, setState] = React.useState([]);
setState(prevState => [...prevState, 'somedata'] );