how to update react state array

JavaScript
const [myArray, setMyArray] = useState([1,2,3])

// to update
setMyArray([...myArray, 4]); // --> myArray = [1,2,3,4]
Source

Also in JavaScript: