Reputation: 15
I am trying to push a project to gh-pages, locally, everything works fine but when I upload it to gh I get this console error "Uncaught TypeError: Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a Symbol.iterator method."
const addToFavorites = (item) => {
setFavorites([...favorites, item]);
saveToLocalStorage([...favorites, item]);
};
this piece of code seems to be the problem but I cannot figure it out
Upvotes: 0
Views: 2209
Reputation: 447
The error is trying to say that your favorites array is not iterable and therefore it is not able to spread them into the array that you are creating in the arguments for setFavorites and saveToLocalStorage. Unless I take a look at your favorites array, I can't give you anymore information
Upvotes: 0