DEV Community

Discussion on: React Shopping Cart Tutorial and Code

Collapse
 
ikeeptrying profile image
Dre

This is excellent! Your demo site works pretty much exactly like I think a shopping cart should work - I've been soooo disappointed lately, looking everywhere for help with this but just about every tutorial and article I found until now, most of them had such basic dumb carts that do not allow for removing items (only emptying the entire cart, all or nothing, like, who does that, really?) or not having options like variations for the item, i.e. small medium large, etc., so, I'm quite happy that yours actually works and has all the functionality.

This is a good starting point for my project. I will have to tweak it a little, because I'm using Gatsby and my data must be accessed via a Graphql query, but that shouldn't be a show stopper. Shouldn't. lol.

That being said, I wonder if you might be getting interested in using hooks or maybe even useState or useEffect? I'm currently learning on my own, and I have not quite gotten it to work yet.

Take a look at this if you are interested; it's really well written and very thorough, and introduced those ideas to me just yesterday: Overreacted

Anyway, great job! 😁

Collapse
 
andersjr1984 profile image
andersjr1984

Thanks Dre!

I've considered rebuilding this using hooks, I may do that if I have the time. Also, I have been thinking my rewrite will push all the shopping cart onto the Firebase server, then attach a listener that updates the render when the user adds or removes an item. Some firebase tools that make this easier are arrayUnion and arrayRemove.

Thanks for the feedback! I'm excited so many people have found use for this tool.