update array of collections inside useState React code example Example: usestate array push setTheArray([...theArray, newElement]);