How to do it...

  1. 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';
  1. 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-thunkpromiseMiddleware must be invoked when it is ...

Get React Native Cookbook - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.