react hooks how to append to array and keep same referenc code example Example: usestate array push setTheArray([...theArray, newElement]);