Użytej pchania tablicy
setTheArray([...theArray, newElement]);
Disgusted Dolphin
setTheArray([...theArray, newElement]);
setTheArray(currentArray => [...currentArray, newElement])
setTheArray([...theArray, newElement]);
const [theArray, setTheArray] = useState(initialArray);