Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add Redux DevTools Extension to my react-redux store?

I'm trying to add the Redux DevTools Chrome extension to my redux store and described here: http://extension.remotedev.io/

Here's my store:

let store;

const initStore = ({onRehydrationComplete}) => {

  store = createStore(
    combineReducers({
      ...reactDeviseReducers,
      form: formReducer,
      router: routerReducer,
      apollo: apolloClient.reducer(),
      cats: catReducer
    }),
    {},
    compose(
      applyMiddleware(
        thunk,
        routerMiddleware(history),
        apolloClient.middleware()
      ),
      autoRehydrate()
    ),
    window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
  );

  persistStore(store, {
    blacklist: [
      'form'
    ]
  }, onRehydrationComplete);

  return store;
};

The extension in Chrome is still showing:

No store found. Make sure to follow the instructions.

Any idea what I'm doing wrong?

like image 993
AnApprentice Avatar asked May 24 '17 16:05

AnApprentice


People also ask

What is Redux DevTools extension?

Redux DevTools for debugging application's state changes. The extension provides power-ups for your Redux development workflow. Apart from Redux, it can be used with any other architectures which handle the state. This is an open source project.

How do I enable Redux DevTools trace?

By default it's disabled as, depending of the use case, generating and serializing stack traces for every action can impact the performance. To enable it, set trace option to true as in examples.

How do I add Redux DevTools to Chrome inspect?

Right-click on the opened extension window and choose Inspect. This will open Chrome Developers Tools and will keep your extension window open until you close the devtools. Right-click on the extension window again and choose Open Remote DevTools under Redux DevTools.


1 Answers

The devtools needs to be within your compose.

Try:

let store;

const initStore = ({onRehydrationComplete}) => {

  store = createStore(
    combineReducers({
      ...reactDeviseReducers,
      form: formReducer,
      router: routerReducer,
      apollo: apolloClient.reducer(),
      cats: catReducer
    }),
    {},
    compose(
      applyMiddleware(
        thunk,
        routerMiddleware(history),
        apolloClient.middleware()
      ),
      autoRehydrate(),
      window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
    )
  );

  persistStore(store, {
    blacklist: [
      'form'
    ]
  }, onRehydrationComplete);

  return store;
};
like image 106
RodCardenas Avatar answered Oct 04 '22 14:10

RodCardenas