- Let's start by adding the new middleware to our Redux store. In the redux/index.js file, let's add the Redux method, applyMiddleware. We'll also add the new middleware we just installed, as follows:
import { combineReducers, createStore, applyMiddleware } from 'redux';import promiseMiddleware from 'redux-promise-middleware';
- In the call to createStore that we defined previously, we can pass in applyMiddleware as the second parameter. applyMiddleware takes one parameter, which is the middleware we want to use, promiseMiddleware:
const store = createStore(reducers, applyMiddleware(promiseMiddleware()));
Unlike some other popular Redux middleware solutions such as redux-thunk, promiseMiddleware must be invoked when it is ...