I think, those are two different tools to solve two different tasks. Hooks perfectly suit when you need to manipulate the local state of the component. If you need to update the global state of the app within Redux store, the whole idea of unidirectional data flow is to use actions dispatched to reducer, exclusively. That's where (described above)mapDispatchToProps and connect come in to play. Or am I missing something?
With hooks it's also possible to update the global state. Therefore react-redux offers useSelector() to get the store data into your component and useDispatch() for dispatching actions. Those functions are a different approach to the connect and mapDispatchToProps code structure.
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.
Maybe you should give hooks a try. You don't have to connect your component via the HOC provided by redux, much cleaner code in my opinion.
You are right, I will write about hooks in the future.
I think, those are two different tools to solve two different tasks. Hooks perfectly suit when you need to manipulate the local state of the component. If you need to update the global state of the app within Redux store, the whole idea of unidirectional data flow is to use actions dispatched to reducer, exclusively. That's where (described above)
mapDispatchToProps
andconnect
come in to play. Or am I missing something?With hooks it's also possible to update the global state. Therefore react-redux offers useSelector() to get the store data into your component and useDispatch() for dispatching actions. Those functions are a different approach to the connect and mapDispatchToProps code structure.