Responsive product-list-with-cart using a pure react
Design comparison
Solution retrospective
I am really produd of how I use to manage the same product information which gonna be added to the cart in the case of updating the quantity of the product using these + and - icons.
What challenges did you encounter, and how did you overcome them?The challenge which I encounter during the challenge was how can I remove the item from the cart and also how can I update the UI to show that a product isn't in the cart anymore. I overcome it by using findIndex method to get the index of the product which gonna be removed from the cart then after I get the index I have added the products to the cart whose index is not equal to the index which I have got first. for the second problem, the way which I used to update the UI was using a state which contains a boolean value. everytime the product is rendered I check the product if it is already in the cart by using it's name property then if it exsists, I will set the state which contains the boolean value to true otherwise I will set it to false then using that state I will set the class I want to the product which I want to be shown as it is already in the cart or not. by using these methods I overcome the problems which I encountered.
What specific areas of your project would you like help with?any feedback on how can I Improve my code is welcomed.
Community feedback
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord