I tried to do the 'save product to the cart's local storage' functionality by myself, but I had a LOT of trouble implementing it, as you can see in my last question.
So I've reset everything back to what is what before I implemented this, because I really want to know how to properly
set this up.
And also, I don't know where to place the local storage function. I originally put it in Products.jsx
because the addToCart() function was there, but then I also have my Cart.jsx
file, which has the removeFromCart() function there. Unless I create one file dedicated to that, and just call the function in both the files? I'm really clueless...
So my question is: can someone please help / demonstrate how to implement this in my code? I've watched a few tutorials on local storage already, but I'm still puzzled.
Help is very
What I have tried:
I've tried looking at YouTube for tutorials on how to add to cart and then save the product to the cart's local storage in React JS, but all the tutorials I watched didn't show you the Local Storage bit. I also searched this up, but got no solutions...