adityaS011 / ecommerce-clone

Flipkart clone built using the MERN (MongoDB, Express.js, React.js, Node.js) stack. The application replicates some of the core features of the popular e-commerce platform Flipkart.
https://mern-clone-flipkart-p2p.netlify.app
MIT License
15 stars 13 forks source link

Persistent Cart Items Disappear on Reload #10

Closed fiskryeziu closed 1 year ago

fiskryeziu commented 1 year ago

Issue Description:

I've encountered an issue where cart items are not persisting upon page reload. When a user adds items to their cart and then refreshes the page or navigates away and returns, the items in the cart are unexpectedly removed.

Steps to Reproduce:

Visit the ecommerce website. Browse products and add items to the shopping cart. Refresh the page or navigate away and return to the cart page.

Expected Behavior:

The items added to the cart should remain in the cart even after page reloads or navigation.

Actual Behavior:

Upon reloading the page or returning to the cart page, the items in the cart are removed, resulting in an empty cart.

adityaS011 commented 1 year ago

how are you proposing to correct that?

fiskryeziu commented 1 year ago

I will use the localstorage when adding item and when removing items from the cart. Also when reload we'll pass to intialState the datafrom localStorage if it's any otherwise return an empty array

adityaS011 commented 1 year ago

done you can work on this, good luck