reactjs - '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
解决方案
只需更改simpleAction
为action
推荐阅读
- python - 使用python脚本增加xml文件中的版本
- java - 带地图的通用通配符
- c++ - 在 Visual Studio 2019 中使用 numeric_limits 的 C++ long double min/max 值错误
- javascript - JS:数组打印重复的值
- javascript - JavaScript 将字符串的首字母大写
- sql - 在 Oracle 中创建一个触发器,用于插入或更新表,同时保持旧记录不变
- jenkins - pod init 状态,同时在 k8s 中使用 helm 安装 jenkins
- python - RGB 到 HSD 转换
- jestjs - 开玩笑测试错误:无法解析 /myProj/public/libs/angularjs-datetime-picker/package.json
- wordpress - 从 Live WordPress 迁移到 Localhost 后,得到“不允许访问页面”