update state in useState which is an empty array code example Example: usestate array push setTheArray([...theArray, newElement]);