MCPcopy
hub / github.com/zalmoxisus/redux-devtools-extension

github.com/zalmoxisus/redux-devtools-extension @2.17.1 sqlite

repository ↗ · DeepWiki ↗ · release 2.17.1 ↗
262 symbols 709 edges 145 files 0 documented · 0%
README

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' createStore.

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

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

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, we’re using Redux compose here.

To specify extension’s options, use it like so:

const composeEnhancers =
  typeof window === 'object' &&
  window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?   
    window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
      // Specify extension’s options like name, actionsBlacklist, 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-dev 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 extension’s options:

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

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

There’re 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, actionsBlacklist, 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: ```js 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 enviroment.

If you don’t 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]

<a href="https://opencollective.com/redux-devtools-exten

Extension points exported contracts — how you extend this code

EnhancerOptions (Interface)
(no doc)
npm-package/index.d.ts

Core symbols most depended-on inside this repo

listenMessage
called by 25
test/utils/inject.js
delay
called by 12
test/utils/e2e.js
render
called by 11
examples/saga-counter/src/main.js
todos
called by 10
examples/todomvc/reducers/todos.js
todos
called by 10
examples/router/reducers/todos.js
relay
called by 8
src/browser/extension/inject/pageScript.js
varNameDeprecatedWarn
called by 8
src/browser/extension/inject/pageScript.js
stringify
called by 8
src/app/api/index.js

Shape

Function 195
Method 35
Class 31
Interface 1

Languages

TypeScript100%

Modules by API surface

src/app/api/index.js22 symbols
src/browser/extension/inject/pageScript.js15 symbols
src/app/middlewares/api.js11 symbols
src/browser/extension/options/syncOptions.js9 symbols
examples/react-counter-messaging/components/Counter.js8 symbols
src/app/api/filters.js7 symbols
examples/todomvc/components/TodoTextInput.js7 symbols
examples/router/components/TodoTextInput.js7 symbols
src/browser/extension/chromeAPIMock.js6 symbols
examples/todomvc/components/TodoItem.js6 symbols
examples/todomvc/components/MainSection.js6 symbols
examples/todomvc/actions/todos.js6 symbols

Dependencies from manifests, versioned

babel-cli6.18.0 · 1×
babel-core6.21.0 · 1×
babel-eslint7.1.0 · 1×
babel-loader7.1.1 · 1×
babel-plugin-add-module-exports0.2.1 · 1×
babel-plugin-react-transform2.0.2 · 1×
babel-plugin-transform-decorators-legacy1.2.0 · 1×
babel-polyfill6.20.0 · 1×
babel-preset-es20156.18.0 · 1×
babel-preset-react6.16.0 · 1×
babel-preset-stage-06.16.0 · 1×
babel-register6.18.0 · 1×

For agents

$ claude mcp add redux-devtools-extension \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact