using push method in react function code example Example: usestate array push setTheArray([...theArray, newElement]);