DEV Community

Discussion on: A Complete Guide to Redux

Collapse
 
domiii profile image
Domi

Hey, great introduction for beginners.
Since you are calling this a complete guide (not a "first look"), you might want to consider the following naggy points (not sure if appreciated or not):

  1. In React hook land, mapXToProps is superceded by useSelector and useDispatch hooks
  2. Don't use useState, unless you have a very good reason to. You want to keep your state management cleanly separated from your components. That is why people (claim to) use Redux in the first place. (Although this inconsistency is prevailant in many production code bases.)
  3. Gif nor article feature "Redux Dev Tools". It's definitely one of the first things you want to use to visualize and analyze your state-action diagram.
  4. A complete guide should contain intermediate and advanced topics, not just the basics; else I'd consider it clickbait. But of course, all of this is just opinion. Maybe you might want to add "Part 1" to the title?
  5. Intermediate and advanced topics should probably largely focus on how to avoid the anti patterns that redux was developed to help you avoid, including keeping things separate, modular and in "flux". Here is some possible inspiration: redux.js.org/style-guide/style-guide

Good luck! Keep on hacking!

Collapse
 
strap8 profile image
Nathan Foster • Edited

I agree with all your points expect the first. The useSelector hook does not give you memoization out of the box like the connect API does. The useSelector uses strict equality while the connect API checks for reference changes between the previous and next props. To achieve the same functionality with the useSelector hook, you can wrap your component with the React.memo HOC.

Collapse
 
anuradha9712 profile image
Anuradha Aggarwal

@domiii Thank you for your feedback. I'll surely look into it!!