Subscribe to my email list now at http://jauyeung.net/subscribe/
Follow me on Twitter at https://twitter.com/AuMayeung
If you want to make a sing...
For further actions, you may consider blocking this person and/or reporting abuse
Use
useDispatch
anduseSelector
instead ofconnect
.It's a pity that you suggest to use
connect
in 2020 🥺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 useuseDispatch/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.
Yea. The hooks have to be in the component. This is inherent to using hooks instead of connect.
react-redux.js.org/next/api/hooks
Thanks for pointing that out.
I have to update that.