update useState array with another array code example Example: usestate array push setTheArray([...theArray, newElement]);