redux Actions may not have an undefined “type“ property. Have you misspelled a constant?

时间:2021-04-03 09:49:48   收藏:0   阅读:21

react-redux 报错

Actions may not have an undefined "type" property. Have you misspelled a constant?

技术分享图片

检查action 中的type 是否和reducer 操作中的type 名称是一致

 

两处用到的 type 需要一致
 
// ./action.js 
// 类型为type:types.USER
export const userAction=(data)=>({type:"类型名称",data});
 
// ./reducer.js
let token =null;
 
export default function Token(_token=token,action){
    //解构中的type用来做判断条件
    const {type,data}=action;
    switch(type){
        case "判断条件":
        return data;
        default:
        return _token;    
    }
    
}

  

 

原文:https://www.cnblogs.com/tianmiaogongzuoshi/p/14613022.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!