jeffersonRibeiro / react-shopping-cart

🛍️ Simple ecommerce cart application built with Typescript and React

Home Page:https://react-shopping-cart-67954.firebaseapp.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

componentWillReceiveProps Alternative

dev-john-nguyen opened this issue · comments

I'm trying to find an alternative way to update the cart without using componentWillReceiveProps since this component lifecycle will be depreciated. I've attempted to use componentDidUpdate, but it updates the cart multiple times. I looked in getDerivedStateFromProps, but it seems to be a little too complicated for my understanding.
I found an alternative solution to update the cart from the Product Component itself when a user clicks on the product, but then I run into the issue of opening the Float Cart when the user adds a new product to the cart.

Any advice/direction would be helpful.

Thanks