我检查了很多类似的问题,还没有找到解决方案,我有一个简单的数组,想要映射显示
var tt = [
{
"age_range": {
"max": 20,
"min": 18,
},
"city": "San Francisco",
"first_name": "Carol",
"gender": "female",
"id": "sfdf",
"infinite": "cc",
"last_name": "Smithberg",
"locale": "en_US",
"name": "Carol Albbhgfefjahc Smithberg",
"option": "Option 3",
"picture": {
"data": {
"height": 960,
"is_silhouette": true,
"url": "https://url",
"width": 1524,
},
},
"sub": "New",
"uid": "dfee",
"updated_time": "2017-10-31T23:52:44+0000",
"verified": false,
}
]
return tt.map((others, index) =>
<View key={others.infinite}>
<Text>{others.sub}</Text>
</View>
);
我收到错误:不变违规,对象无效作为React子对象(找到了带有键{_40,_65,_55,_72}的对象)如果要渲染子集合,请使用数组代替
{other.sub}
绝对是一个字符串,我也试过
return tt.map(({ ...others }, index) =>
<View key={others.infinite}>
<Text>{others.sub}</Text>
</View>
);
并得到同样的错误,最有希望solution我发现我坚持认为我作为{...item}
传递,然后作为props.{property}
进行访问,但我并不完全理解这一点,我该如何解决这个问题?
答案 0 :(得分:0)
使用此工具时,我遇到了同样的错误
render = async () => {
代替此
render() {