import { useState } from "react"; const yourComponent = () => { const [array, setArray] = useState([]); }
var ar = [1, 2, 3, 4, 5, 6]; //do stuffar = []; //a new, empty array!
const newArray = [...array, source]; setArray(newArray);