Duration
1 min
Access
Free
Transcript
Available

Redux provides a useDispatch hook to make it easy to dispatch actions within a function component. This hook replaces the mapDispatchToProps function which was used previously with connect().

The basic API looks like this:

const dispatch = useDispatch();

Within a component you can choose to use dispatch() directly, within an event handler for example, or create a function to that dispatches the action and reference that. This lesson shows both options.