DEV Community

Discussion on: How To Use Redux With React

Collapse
 
garrisond profile image
Ihor Dotsenko

Use useDispatch and useSelector instead of connect.

It's a pity that you suggest to use connect in 2020 🥺

Collapse
 
garrisond profile image
Ihor Dotsenko
Collapse
 
aumayeung profile image
John Au-Yeung

Thanks for pointing that out.

I have to update that.

Collapse
 
dance2die profile image
Sung M. Kim • Edited

Redux hooks have ups and downs compared to connect.

connect lets you decouple your component (making it resuable) but a lot of times that abstraction might not be needed. Then you'd use useDispatch/useSelector. But hooks are really darn easy though, and more readable even though it's usable only within function components.

So the bottomline is knowing both ways would help understand trade-offs and when to use each one.

Collapse
 
aumayeung profile image
John Au-Yeung

Yea. The hooks have to be in the component. This is inherent to using hooks instead of connect.