array state reactjs functional component examples Example: usestate array push setTheArray([...theArray, newElement]);