如何使用redux saga运行redux开发工具?

如何使用redux saga运行redux开发工具?,redux,react-redux,redux-saga,Redux,React Redux,Redux Saga,尝试使用redux传奇运行reduxdevtools: 获取此错误: Error Before running a Saga, you must mount the Saga middleware on the Store using applyMiddleware 这是我的代码: const store = createStore( reducer, applyMiddleware(sagaMiddleware), window.__REDUX_DEVTOOLS_EXTENSIO

尝试使用redux传奇运行reduxdevtools:

获取此错误:

Error
Before running a Saga, you must mount the Saga middleware on the Store using applyMiddleware
这是我的代码:

const store = createStore(
  reducer,
  applyMiddleware(sagaMiddleware),
  window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
);
如何使用saga运行此开发工具?或者,如果不是这样,什么会起作用?

我已经按照这里的描述使用了

添加包后,我用以下内容替换了商店定义:

const store = createStore(
  reducer,
  composeWithDevTools(
    applyMiddleware(sagaMiddleware)
  )
);
前面的答案(由trkaplan提供)使用了从“redux devtools extension”包中导入的composeWithDevTools方法。 如果不想安装此软件包,可以使用此代码(基于):

const composeEnhancers=typeof window=='object'和&window[''''u REDUX\u DEVTOOLS\u EXTENSION\u COMPOSE']?
窗口[''''u REDUX'u DEVTOOLS'u EXTENSION'u COMPOSE']({}):COMPOSE;
常量增强子=复合增强子(
applyMiddleware(thunkMiddleware、sagaMiddleware、/*其他中间件*/),
/*其他商店增强器(如有)*/
);
常量emptyReducer=()=>{};
const store=createStore(清空导出器、增强器);

在使用Redux的情况下。下面的代码很有用。 步骤1:添加chrome Redux开发工具扩展。 步骤2:npm安装redux devtools扩展

    import { composeWithDevTools } from 'redux-devtools-extension';
    const store = createStore(
                  reducer,
                  compose(
                  applyMiddleware(sagaMiddleware),
                  composeWithDevTools(),
                  ),
                  );

这就是为实际项目配置redux、redux devtool扩展和redux传奇的方式

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

import rootReducer from '../reducers';
import rootSaga from '../sagas';

const configureStore = () => {
    const sagaMiddleware = createSagaMiddleware();
    return {
        ...createStore(rootReducer, composeWithDevTools(applyMiddleware(sagaMiddleware))),
        runSaga: sagaMiddleware.run(rootSaga),
    };
};

export default configureStore;

这是固定的代码笔链接。