Redux Logger

Install redux-logger:

npm install redux-logger

Then add this logger to your store. Note the extra code so the logger only runs in development mode:

import { compose, createStore, applyMiddleware } from "redux";
import logger from "redux-logger";

import { rootReducer } from "./root-reducer";

const middleWares = [process.env.NODE_ENV !=='production' && logger].filter(Boolean);

const composedEnhancers = compose(applyMiddleware(...middleWares));

export const store = createStore(rootReducer, undefined, composedEnhancers);

Leave a Reply

Your email address will not be published. Required fields are marked *