const [cart, setCart] = useState([]);
const addToCart = (item) => {
// cart.push(item);
setCart(...cart, item);
console.log(cart);
};
when I try to update cart with cart.push() , it is updating cart but when i try to update cart with setCart then its showing this error
=> TypeError: object is not iterable (cannot read property Symbol(Symbol.iterator))