我对react-redux
相当新,我收到了这个奇怪的错误。它说我的rootReducer
没有定义。 rootReducer
是我合并减速器后创建的常量。这是我的代码:
import {combineReducers} from 'redux';
import taskReducer from './handle-action';
rootReducer = combineReducers({
tasks: taskReducer
});
export default rootReducer;
我错过了什么?
答案 0 :(得分:2)
您错过了定义rootReducer
变量
const rootReducer = combineReducers({ tasks: taskReducer });
或
export default combineReducers({ tasks: taskReducer });
答案 1 :(得分:1)
无论您导出的是什么,都必须是变量或函数,因此它应该是const or var or let
import {combineReducers} from 'redux';
import taskReducer from './handle-action';
const rootReducer = combineReducers({
tasks: taskReducer
});
export default rootReducer;