push to a list with usestate hook react code example Example: usestate array push setTheArray([...theArray, newElement]);