How to run redux devtools with redux saga?

I've used redux-devtools-extension package as described here, redux-devtools-extension documentation.

After adding the package, I've replaced the store definition with this:

const store = createStore(
  reducer,
  composeWithDevTools(
    applyMiddleware(sagaMiddleware)
  )
);

Fixed Codepen Link


The previous answer (by trkaplan) uses an imported method composeWithDevTools from 'redux-devtools-extension' package. If you don't want to install this package, you may use this code (based on the docs):

      const composeEnhancers =  typeof window === 'object' && window['__REDUX_DEVTOOLS_EXTENSION_COMPOSE__'] ? 
      window['__REDUX_DEVTOOLS_EXTENSION_COMPOSE__']({ }) : compose;
      const enhancer = composeEnhancers(
        applyMiddleware(thunkMiddleware, sagaMiddleware, /*other middleware*/),
        /* other store enhancers if any */
      );
      const emptyReducer = () => {};
      const store = createStore(emptyReducer, enhancer);