Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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 much appreciated,
Thanks!

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...
Posted
Updated 17-Nov-20 2:12am
v3
Comments
[no name] 14-Nov-20 10:05am    
"Local storage" is a cookie.
h311o 15-Nov-20 1:39am    
@salty06 okay, thanks for the info :)
Richard Deeming 16-Nov-20 3:05am    
[no name] 16-Nov-20 11:59am    
It's 2 mints in one.
h311o 16-Nov-20 20:22pm    
So it's not a cookie?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900