redux-immutable-state-invariant icon indicating copy to clipboard operation
redux-immutable-state-invariant copied to clipboard

doesn't work with redux-devtools-extension

Open desm opened this issue 5 years ago • 3 comments

I use the following TypeScript code to setup Redux' middlewares: (Note: for dev purposes only)

if (typeof window !== 'undefined') {
  if ((window as any).__REDUX_DEVTOOLS_EXTENSION__) {
    enhancer = compose(
      installReduxLoop(),
      (window as any).__REDUX_DEVTOOLS_EXTENSION__({ trace: true, traceLimit: 25 }),
      applyMiddleware(require('redux-immutable-state-invariant').default())
    )
  }
  // ...
}

I have found that I need to comment out the call to __REDUX_DEVTOOLS_EXTENSION__(...) in order for redux-immutable-state-invariant to work properly, otherwise incorrect mutations are detected for everything. Perhaps a note could be added that the 2 middlewares/extensions are incompatible? Thanks.

desm avatar Feb 28 '19 12:02 desm

If it helps, I've had success with the following setup that doesn't call REDUX_DEVTOOLS_EXTENSION directly:

import {applyMiddleware, compose, createStore} from "redux";
import myReducer from "./reducers/myReducer";
import {install} from "redux-loop";
import {default as installInvariant} from 'redux-immutable-state-invariant';

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;

export const store = createStore(
    myReducer,
    {}, 
    composeEnhancers(

        applyMiddleware(
            installInvariant()),
            install()));

j1m-renwick avatar Feb 26 '20 23:02 j1m-renwick

@j1m-renwick I tried the approach you suggested, but I am still getting the window is not defined.

event - compiled successfully
ReferenceError: window is not defined
    at eval (webpack-internal:///./src/redux/store/configureStore.dev.js:18:26)

cksachdev avatar Jun 14 '21 14:06 cksachdev

I'm sorry for the late reply. You can close this issue if you'd like.

desm avatar Feb 06 '24 18:02 desm