我正在尝试根据t he steps in the README来建立连接的反应路由器。
我的store.js中有以下当前代码:
Estimator
我尝试按照设置进行操作,但是在浏览器中始终出现model_fn
错误。
当前文件如下所示:
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;
答案 0 :(得分:0)
给connectRouter history
而不是化简器。所以:
connectRouter(history)(reducer),
代替connectRouter(reducer)(history)
。
您说import reducer from './reducers';
指的是包含化简器的文件夹。假设reducers文件夹包含三个文件(index.js,reducer1.js和reducer2.js),那么在reducers
中使用类似的文件应该可以工作:
Index.js
import reducer1 from './reducer1';
import reducer2 from './reducer2';
import { combineReducers } from 'redux';
export default combineReducers({ reducer1, reducer2 });
reducer1.js
const reducer1 = (state = { myState: "foo" }, action) => {
return state;
};
export default reducer1;
reducer2.js
const reducer2 = (state = { myState: "bar" }, action) => {
return state;
};
export default reducer2;