Reducer 中代码是否出现了错误 ?
来源:15-2 Redux项目集成(1)

刘宁Leo
2018-12-14
对于 reducer 中的 index.js 中的代码存在疑问:
export default (state = initialState, action) => {
switch (action) {
case type.SWITCH_MENU:
return {
...state,
menuName: action.menuName
};
default:
break;
}
};
switch(action)
是否应该是switch(action.type)
?default
后面是否应该return state
?
写回答
1回答
-
没错,代码有问题,这个地方应该是action.type
012018-12-15
相似问题