push array recat hooks code example
Example 1: usestate array push
setTheArray([...theArray, newElement]);
Example 2: adding to array using reach hooks
setMyArray(oldArray => [...oldArray, newElement]);
setTheArray([...theArray, newElement]);
setMyArray(oldArray => [...oldArray, newElement]);