redux-devtools/extension
Nathan Bierema ba5bd18d5b Publish
- remotedev-redux-devtools-extension@3.0.0
 - d3-state-visualizer@1.4.2
 - d3tooltip@1.3.2
 - map2tree@1.5.2
 - react-base16-styling@0.8.2
 - react-dock@0.4.2
 - react-json-tree@0.15.2
 - @redux-devtools/app@1.0.0
 - @redux-devtools/chart-monitor@1.9.2
 - @redux-devtools/cli@1.0.0
 - @redux-devtools/dock-monitor@1.4.2
 - @redux-devtools/extension@3.0.0
 - @redux-devtools/inspector-monitor-test-tab@0.7.4
 - @redux-devtools/inspector-monitor-trace-tab@0.2.4
 - @redux-devtools/inspector-monitor@1.0.2
 - @redux-devtools/instrument@1.11.2
 - @redux-devtools/log-monitor@2.3.2
 - @redux-devtools/remote@0.6.1
 - @redux-devtools/rtk-query-monitor@1.0.2
 - @redux-devtools/serialize@0.3.2
 - @redux-devtools/slider-monitor@2.0.0
 - @redux-devtools/ui@1.0.0
 - @redux-devtools/utils@1.0.0
 - @redux-devtools/core@3.9.2
 - d3-state-visualizer-tree-example@0.1.2
 - react-dock-demo@0.1.2
 - react-json-tree-example@1.1.4
 - test-demo@0.1.2
 - inspector-demo@0.1.2
 - rtk-query-demo@0.1.2
 - slider-todomvc@0.1.4
 - counter-redux@0.1.4
 - todomvc@0.2.3
2022-01-07 21:24:58 -05:00
..
docs feat(extension): replace whitelist/blacklist with allowlist/denylist (#851) 2021-09-06 20:07:44 +00:00
examples chore(*): upgrade prettier (#743) 2021-06-17 23:56:36 -04:00
src Bump extension version number 2022-01-07 21:11:39 -05:00
test chore(deps): update dependency chromedriver to v96 (#962) 2021-12-04 13:41:26 -05:00
webpack Remove deprecated inject scripts (#947) 2021-11-06 04:23:00 +00:00
.babelrc chore(*): clean up babel configs (#816) 2021-08-29 23:25:48 +00:00
.bookignore chore(extension): add extension (#658) 2020-10-26 08:18:23 -04:00
.eslintignore chore(extension): switch to Jest (#679) 2020-12-19 15:01:09 -05:00
.eslintrc chore(extension): upgrade gulp (#662) 2020-10-31 07:51:20 -05:00
.gitignore chore(extension): use Yarn 2 (#735) 2021-06-14 17:50:06 -04:00
appveyor.yml chore(extension): add extension (#658) 2020-10-26 08:18:23 -04:00
book.json chore(extension): add extension (#658) 2020-10-26 08:18:23 -04:00
CHANGELOG.md chore(extension): add extension (#658) 2020-10-26 08:18:23 -04:00
CODE_OF_CONDUCT.md chore(extension): add extension (#658) 2020-10-26 08:18:23 -04:00
jest.config.js fix(extension): fix code editor styles (#817) 2021-08-30 01:32:29 +00:00
LICENSE chore(extension): add extension (#658) 2020-10-26 08:18:23 -04:00
package.json Publish 2022-01-07 21:24:58 -05:00
README.md feat(extension): replace whitelist/blacklist with allowlist/denylist (#851) 2021-09-06 20:07:44 +00:00
SUMMARY.md chore(extension): add extension (#658) 2020-10-26 08:18:23 -04:00
tsconfig.json chore(extension): convert to TypeScript (#756) 2021-08-25 00:22:54 -04:00

Redux DevTools Extension

Join the chat at https://gitter.im/zalmoxisus/redux-devtools-extension PRs Welcome OpenCollective OpenCollective

Demo

Installation

1. For Chrome

2. For Firefox

3. For Electron

4. For other browsers and non-browser environment

Usage

Note that starting from v2.7, window.devToolsExtension was renamed to window.__REDUX_DEVTOOLS_EXTENSION__ / window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__.

1. With Redux

1.1 Basic store

For a basic Redux store simply add:

 const store = createStore(
   reducer, /* preloadedState, */
+  window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
 );

Note that preloadedState argument is optional in Redux's createStore.

For universal ("isomorphic") apps, prefix it with typeof window !== 'undefined' &&.

const composeEnhancers =
  (typeof window !== 'undefined' &&
    window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) ||
  compose;

For TypeScript use redux-devtools-extension npm package, which contains all the definitions, or just use (window as any) (see Recipes for an example).

const composeEnhancers = (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;

In case ESLint is configured to not allow using the underscore dangle, wrap it like so:

+ /* eslint-disable no-underscore-dangle */
  const store = createStore(
   reducer, /* preloadedState, */
   window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
  );
+ /* eslint-enable */

Note: Passing enhancer as last argument requires redux@>=3.1.0. For older versions apply it like here or here. Don't mix the old Redux API with the new one.

You don't need to npm install redux-devtools when using the extension (that's a different lib).

1.2 Advanced store setup

If you setup your store with middleware and enhancers, change:

  import { createStore, applyMiddleware, compose } from 'redux';

+ const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
+ const store = createStore(reducer, /* preloadedState, */ composeEnhancers(
- const store = createStore(reducer, /* preloadedState, */ compose(
    applyMiddleware(...middleware)
  ));

Note that when the extension is not installed, were using Redux compose here.

To specify extensions options, use it like so:

const composeEnhancers =
  typeof window === 'object' && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
    ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
        // Specify extensions options like name, actionsDenylist, actionsCreators, serialize...
      })
    : compose;

const enhancer = composeEnhancers(
  applyMiddleware(...middleware)
  // other store enhancers if any
);
const store = createStore(reducer, enhancer);

See the post for more details.

1.3 Use redux-devtools-extension package from npm

To make things easier, there's an npm package to install:

npm install --save redux-devtools-extension

and to use like so:

import { createStore, applyMiddleware } from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension';

const store = createStore(
  reducer,
  composeWithDevTools(
    applyMiddleware(...middleware)
    // other store enhancers if any
  )
);

To specify extensions options:

import { createStore, applyMiddleware } from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension';

const composeEnhancers = composeWithDevTools({
  // Specify name here, actionsDenylist, actionsCreators and other options if needed
});
const store = createStore(
  reducer,
  /* preloadedState, */ composeEnhancers(
    applyMiddleware(...middleware)
    // other store enhancers if any
  )
);

Therere just few lines of code added to your bundle.

In case you don't include other enhancers and middlewares, just use devToolsEnhancer:

import { createStore } from 'redux';
import { devToolsEnhancer } from 'redux-devtools-extension';

const store = createStore(
  reducer,
  /* preloadedState, */ devToolsEnhancer()
  // Specify name here, actionsDenylist, actionsCreators and other options if needed
);

1.4 Using in production

It's useful to include the extension in production as well. Usually you can use it for development.

If you want to restrict it there, use redux-devtools-extension/logOnlyInProduction:

import { createStore } from 'redux';
import { devToolsEnhancer } from 'redux-devtools-extension/logOnlyInProduction';

const store = createStore(
  reducer,
  /* preloadedState, */ devToolsEnhancer()
  // options like actionSanitizer, stateSanitizer
);

or with middlewares and enhancers:

import { createStore, applyMiddleware } from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension/logOnlyInProduction';

const composeEnhancers = composeWithDevTools({
  // options like actionSanitizer, stateSanitizer
});
const store = createStore(
  reducer,
  /* preloadedState, */ composeEnhancers(
    applyMiddleware(...middleware)
    // other store enhancers if any
  )
);

You'll have to add 'process.env.NODE_ENV': JSON.stringify('production') in your Webpack config for the production bundle (to envify). If you use create-react-app, it already does it for you.

If you're already checking process.env.NODE_ENV when creating the store, include redux-devtools-extension/logOnly for production environment.

If you dont want to allow the extension in production, just use redux-devtools-extension/developmentOnly.

See the article for more details.

1.5 For React Native, hybrid, desktop and server side Redux apps

For React Native we can use react-native-debugger, which already included the same API with Redux DevTools Extension.

For most platforms, include Remote Redux DevTools's store enhancer, and from the extension's context menu choose 'Open Remote DevTools' for remote monitoring.

2. Without Redux

See integrations and the blog post for more details on how to use the extension with any architecture.

Docs

Demo

Live demos to use the extension with:

Also see ./examples folder.

Backers

Support us with a monthly donation and help us continue our activities. [Become a backer]

Sponsors

Become a sponsor and get your logo on our README on Github with a link to your site. [Become a sponsor]

License

MIT

Created By

If you like this, follow @mdiordiev on twitter.