我正在尝试根据README 中的步骤设置 connected-react-router 。
我的 store.js 中有这个当前代码:
import { createStore } from 'redux';
import reducer from './reducers';
import { middleware, runSagas } from './middleware';
const createSWStore = () => {
const store = createStore(reducer, middleware);
runSagas();
return store;
};
export default createSWStore;
我尝试按照设置进行操作,但Uncaught TypeError: rootReducer is not a function
浏览器中不断出现错误。
目前该文件如下所示:
import { createBrowserHistory } from 'history';
import { applyMiddleware, compose, createStore } from 'redux';
import { connectRouter, routerMiddleware } from 'connected-react-router';
import reducer from './reducers';
import { middleware, runSagas } from './middleware';
const history = createBrowserHistory();
const createSWStore = () => {
const store = createStore(
connectRouter(reducer)(history),
compose(
applyMiddleware(
routerMiddleware(history),
),
),
middleware);
runSagas();
return store;
};
export default createSWStore;