Sometimes, we want to dispatch multiple actions in Redux and JavaScript.
In this article, we’ll look at how to dispatch multiple actions in Redux and JavaScript.
How to dispatch multiple actions in Redux and JavaScript?
To dispatch multiple actions in Redux and JavaScript, we call dispatch multiple times.
For instance, we write
const action1 = (id) => {
return (dispatch) => {
dispatch(action2(id));
dispatch(action3(id));
};
};
to call dispatch with all the actions we want to dispatch in the function returned by action1.
Conclusion
To dispatch multiple actions in Redux and JavaScript, we call dispatch multiple times.