react push usestate code example
Example 1: usestate array push
setTheArray([...theArray, newElement]);
Example 2: push-method-in-react-hooks-usestate
const [theArray, setTheArray] = useState(initialArray);
setTheArray(theArray => [...theArray, newElement]);