react useState set one element of array code example Example: usestate array push setTheArray([...theArray, newElement]);