Search code examples
reduxredux-devtools-extension

redux devtools config not working


I am trying to configure my app to use the redux-devtools but it's somehow not working.

here was my config before using redux-devtools

var persistedState = loadState();

var createStoreWithMiddleware = compose(applyMiddleware(thunk,loadingBarMiddleware(),errorBarMiddleware()),reduxReset())(createStore);

export var store = createStoreWithMiddleware(reducers,persistedState);

Here's what i did to use redux-devtools

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
var createStoreWithMiddleware = compose(applyMiddleware(thunk,loadingBarMiddleware(),errorBarMiddleware()),reduxReset())(createStore);

const store = createStore(reducers, /* preloadedState, */ composeEnhancers(
  createStoreWithMiddleware(reducers,persistedState)
));

but with this I am getting the error

Uncaught TypeError: reducer is not a function

So, where am I going wrong with this?


Solution

  • Well, I figured out the problem and now it's working for me.

    all, I had to do was to add the redux devtools code to my previous code like this. seems like I was making it more complicated than it should have been.

    anyways, the working code is

    var persistedState = loadState();
    
    var createStoreWithMiddleware = compose(applyMiddleware(thunk,loadingBarMiddleware(),errorBarMiddleware()),reduxReset())(createStore);
    
    export var store = createStoreWithMiddleware(reducers,persistedState,window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__());
    

    it was as simple as that.