【发布时间】:2023-08-22 04:47:01
【问题描述】:
我想在我的项目中使用 redux-saga,安装 redux-saga 后,当我在 store.js 文件中进行更改时会报错
错误:您似乎将几个存储增强器传递给 createStore()。这是不支持的。相反,将它们组合成一个函数。
# store.js
import { createStore, applyMiddleware, compose } from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension';
import thunk from 'redux-thunk';
import rootReducer from './reducers'
import createSagaMiddleware from 'redux-saga';
import rootSaga from './actions/sagas';
const sagaMiddleware = createSagaMiddleware();
const composeEnhancers =
typeof window === 'object' &&
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
// Specify extension’s options like name, actionsBlacklist, actionsCreators, serialize...
}) : compose;
const enhancer = composeEnhancers(
applyMiddleware(sagaMiddleware)
);
const initialState = {};
const middleware = [thunk];
const store = createStore(
rootReducer,
initialState,
enhancer,
composeWithDevTools(applyMiddleware(...middleware))
);
sagaMiddleware.run(rootSaga);
export default store;
我对商店了解不多。请看看你能不能帮忙。
【问题讨论】:
标签: reactjs redux react-redux redux-saga