add object to an array in react code example Example: add array of object to state react setTheArray(currentArray => [...currentArray, newElement])