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-thunk, promiseMiddleware must be invoked when it is ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.