首页 > 解决方案 > 'action' 没有在 reducer 中定义 - React, Redux

问题描述

我已经设置了一个减速器,但是控制台抱怨“动作”没有定义 no-undef

import { getName } from '../actions';
let defaultState={
 name: "Sam"
}
const mainReducer=(state = defaultState, simpleAction)=>{
if (action.type === "CHANGE_NAME") {
return{
  ...state,
  name: action.name
}

} else {
return{
  ...state
}
}
}

export default mainReducer

标签: reactjsredux

解决方案


只需更改simpleActionaction


推荐阅读