Welcome to part-7 of the series. You can find part-6 here. We will learn to use logger middleware in a react-redux app and also to install and use redux devtool.
We had earlier seen how to install and use logger middleware in our redux application, now we will see the same in react-redux application.
The first step is to install the package, so open the terminal and install it in our react-redux application folder.
Now, to use it we need to open our store.js file and do the below changes.
This logger middleware basically logs the log related to redux store. So, open up the application and the console.
After that click on Buy Egg button and now we can see the logs from the redux state changes.
We will look into a great tool, which is very essential when you are building a react-redux application.
This is basically a browser extension, which is available for both chrome and firefox.
I am using firefox, so have installed the extension for firefox.
The next step is to add the redux devtool extension to our react-redux application. The instruction are in this link. As per the instructions, we have to do a npm install.
So, stop the npm start and do the npm install in the terminal.
The next step is to use it in the store.js file. We do the necessary import and pass the applyMiddleware to composeWithDevTools.
After this restart the project with npm start. Open the console and select the redux devtool.
Now, the initial screen shows the global state containing egg and chicken.
Now, when we click any button an action will be dispatched and shown in the other panel and the global state will also be changed.
Now, we can also see the different action transition, by clicking on the play button near the bottom.