src/reducers文件夹中的2个文件:index.js todo.js
1 index.js
import { combineReducers } from 'redux'
import todos from './todos'
const rootReducer = combineReducers({
todos
})
export default rootReducer
2 todo.js
//省略
export default function todos(state = initialState, action) {
//省略
我的问题是,如果把todo.js里的todos改个名,比如改为todos11,同时把index.js相应改为
import { combineReducers } from 'redux'
import todos11 from './todos'
const rootReducer = combineReducers({
todos11
})
export default rootReducer
这样对程序功能没有任何影响,程序应该能继续工作,但是却报错。我看了todomvc/src里所有的文件,只有index.js引用了todo.js,其它的文件并未引用todo.js。所以这是为什么呢?报错如下所示
mapStateToProps里面用到了你的todos规则函数的也就是combineReducers里面的todos1,所以你mapStateToProps里面的todos应该也要改变