If you want to update an array that is part of the state, use the spread operator in order to combine the old array with the new array entry:

const MyComponent = () => {

const [array, setArray] = useState([]);


setArray((prevArray) => [...prevArray, newEntry]);

};

export default MyComponent;