Redux Dev Tools
by John Vincent
Posted on January 21, 2019
Converting to use Redux DevTools Extension.
Introduction
Chrome Installation
Install Redux DevTools from the Chrome Web Store
An icon should be added to your chrome browser.
Usage
Use the icon to activate. An in-browser Redux Inspector window is opened.
In practice, it is best to open a separate window. To do this, click any of the three icons at the bottom left of the panel.
Debugging
Can store redux state between page refreshes.
For example
http://localhost:8002/?debug_session=my1
Also can store multiple states, for example
http://localhost:8002/?debug_session=my2
To return to a saved state, just re-enter the url.
When finished, disable debugging
http://localhost:8002
Code
The code now gets much easier
index.jsx
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import Root from './root/Root';
import configureStore from './store/configureStore';
const store = configureStore();
document.addEventListener('DOMContentLoaded', () => {
ReactDOM.render(
<Provider store={store}>
<Root />
</Provider>,
document.getElementById('root')
);
});
/store/configureStore.js
if (process.env.NODE_ENV === 'production') {
module.exports = require('./configureStore.prod');
} else {
module.exports = require('./configureStore.dev');
}
/store/configureStore.dev.js
import { createStore, applyMiddleware, compose } from 'redux';
import thunk from 'redux-thunk';
import rootReducer from '../redux/reducers';
const configureStore = (initialState = {}) => {
const middleware = [thunk];
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose; // eslint-disable-line no-underscore-dangle
const enhancers = composeEnhancers(
applyMiddleware(...middleware)
);
const store = createStore(rootReducer, initialState, enhancers);
return store;
};
export default configureStore;
/store/configureStore.prod.js
import { createStore, compose, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import rootReducer from '../redux/reducers';
const configureStore = (initialState = {}) => {
const middleware = [thunk];
const enhancers = [];
const store = createStore(rootReducer, initialState, compose(applyMiddleware(...middleware), ...enhancers));
return store;
};
export default configureStore;
Root.jsx
is now the same for development and production.
Converting From redux-devtools
Remove packages
redux-devtools
redux-devtools-log-monitor
redux-devtools-dock-monitor
React
- Basic React
- Basic React Patterns
- Basic React Redux
- Basic React Redux App
- Basic React Testing with Jest and Enzyme
- Building and deploying MyTunes to johnvincent.io
- Building and deploying React Github Helper App to johnvincent.io
- Deploy React App to Heroku using Travis Continuous Integration
- Deploy TaskMuncher React App to AWS
- First time deploy TaskMuncher React App to Digital Ocean
- Gatsby and Client Only Components
- Gatsby Getting Started
- Gatsby React Icons
- Mac Visual Studio Code
- Material-UI
- Material-UI Pickers
- Material-UI Styling
- Optimizing TaskMuncher with Webpack 4
- Overview of React Gomoku
- Overview of React Hangman
- Overview of React Lights Out
- Overview of React Yahtzee
- React Material-UI
- React Production Issues
- React PropTypes
- React/Redux Node/Express Ecosystem
- Redux Dev Tools
- Responsive Material-UI
- Styling Material-UI components using Styled-Components
- TaskMuncher Performance
- Transforming Html with Webpack
- Update TaskMuncher for Lighthouse Findings
- Update TaskMuncher to be a Progressive Web App
- Update TaskMuncher to use React BrowserRouter
- Update TaskMuncher to Webpack v4, Babel v7, Material-UI v3
- Upgrading Babel and ESLint to use React Advanced Language Features
- Webpack Bundle Analyzer