Yeah, I get what you're saying. It's just interesting to see how connect is sometimes described as being a lot harder to understand. mapState and useSelector are basically equivalent. mapDispatch is admittedly doing a couple more steps than useDispatch, but ultimately the behavior is the same (and really code like () => dispatch(increaseVote(anime.id) is actually doing some work that mapDispatch did for you.)
FWIW, I'm working on a major rewrite of the Redux core docs, and my next step is to add a new tutorial page that teaches Redux Toolkit and the React-Redux hooks as the default way to use Redux. It'll be interesting to see how that turns out.
I think because 'connect' is actually where the magic happen. We do not see any code but our components gets store and functions from redux. I think also from the javascript point of view it's not common and easy to read somethings like function(function, function)(function)
Can't wait to use the toolkit in my next project!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Yeah, I get what you're saying. It's just interesting to see how
connect
is sometimes described as being a lot harder to understand.mapState
anduseSelector
are basically equivalent.mapDispatch
is admittedly doing a couple more steps thanuseDispatch
, but ultimately the behavior is the same (and really code like() => dispatch(increaseVote(anime.id)
is actually doing some work thatmapDispatch
did for you.)FWIW, I'm working on a major rewrite of the Redux core docs, and my next step is to add a new tutorial page that teaches Redux Toolkit and the React-Redux hooks as the default way to use Redux. It'll be interesting to see how that turns out.
I think because 'connect' is actually where the magic happen. We do not see any code but our components gets store and functions from redux. I think also from the javascript point of view it's not common and easy to read somethings like function(function, function)(function)
Can't wait to use the toolkit in my next project!