Replies: 2 comments 28 replies
-
Hi @sktguha! IMO, these aren't problems, but just poor design decisions. The example of multiple shopping carts is interesting, but the concept of adding booleans to track separate carts shows a lack of understanding of best practices. I would guess that if the author revisited this subject, they'd most likely want to rewrite the majority of this. What this article doesn't address with its local state approach in the e-commerce scenario is something as simple as showing a cart total + quantity in a navbar. As soon as you do that, you're going to introduce a different state solution, so basically, every point raised here is irrelevant. In terms of modern react-redux, you could very easily implement this exact scenario with hooks and just giving each cart a temporary id and having a slice structure like At the end of the day, I'm pretty sure this article is just complaining about redux boilerplate, which is mostly solved by Redux Toolkit. Judging by the last update that is quoted below, I'd just disregard this whole thing.
If you have specific issues that are relevant to what you're actively working on, I'd bring those up instead of the points in this article, as what is represented there are outdated complaints that were most likely given just to promote the author's own library. If you look at that quote above, they're now basically recommending re-implementing Redux, but most likely in a less performant manner. @markerikson has many articles on the topic of Redux vs Context that have been linked many times - here is a relevant thread from yesterday that include such links. If you're actively in need of help with Redux best practices and implementation approaches, I'd recommend reading the latest fundamentals guide, then checking out #redux on reactiflux where there are many people that can help you. |
Beta Was this translation helpful? Give feedback.
-
Adding to all this: if you have state that is created when a component mounts and should be removed when a component unmounts, that is local component state. It belongs into your component. |
Beta Was this translation helpful? Give feedback.
-
What is the solution to the two problems mentioned in this article ? ( don't agree too much with the rest of the article though) ,
https://codeburst.io/the-ugly-side-of-redux-6591fde68200#fa23:~:text=The%20store%E2%80%99s%20life%20cycle%20is%20different%20from%20the%20components%E2%80%99%20life%20cycle
https://codeburst.io/the-ugly-side-of-redux-6591fde68200#a6cf:~:text=The%20global%20store%20is%20a%20singleton%2C%20but%20a%20component%20may%20have%20many%20instances
I have myself run into both problems personally.
Beta Was this translation helpful? Give feedback.
All reactions