DEV Community

Discussion on: Connect a React component to a Redux action

Collapse
 
ygorbunkov profile image
ygorbunkov

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?

Collapse
 
highasthedn profile image
highasthedn

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.