1. 22
    Create Redux Middleware to Dispatch Multiple Actions
    2m 43s

Create Redux Middleware to Dispatch Multiple Actions

Share this video with your friends

Send Tweet

We only have a few dispatching functions that need to be known by our React Application. Each one actually has multiple actions that need to be dispatched. While we could just have many imperative calls to dispatch in our dispatching functions, but why not use it as an excuse to use an array and write some middleware.

We will create a middleware function that will check dispatched actions to see if they are arrays. If a given action is an array we loop over the array, dispatching each action in turn. If it is not however, we just pass it along to be handled downstream.