react add new object to state array hook code example Example: add object to array react hook setTheArray([...theArray, newElement]);