how to set array as state in react code example
Example: how to update react state array
const [myArray, setMyArray] = useState([1,2,3])
// to update
setMyArray([...myArray, 4]); // --> myArray = [1,2,3,4]
const [myArray, setMyArray] = useState([1,2,3])
// to update
setMyArray([...myArray, 4]); // --> myArray = [1,2,3,4]