[英]React Native receive error when spread operator is used in props assignment: "In this environment the target of assign must be an object
I'm currently using React with Redux and when I run the following: 我目前正在使用React与Redux,当我运行以下内容时:
const mapStateToProps = state => {
const employees = _.map(state.employees, (val, uid) => {
return { ...val, uid };
});
I get the error stated above which seems to be targeting "...val" in the return method. 我得到上面所述的错误,似乎是在返回方法中以“... val”为目标。 I'm basically trying to pull all the information I had from Firebase and returning it in the variable "employees." 我基本上试图从Firebase获取所有信息并将其返回到变量“employees”中。 Any help would be appreciated, thanks! 任何帮助将不胜感激,谢谢!
I think the issue is the typeof val
isn't an object (either an array[] or an object {}). 我认为问题是typeof val
不是一个对象(array []或object {})。 You can just use return {val, uid}
你可以使用return {val, uid}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.