【发布时间】:2018-12-22 09:45:24
【问题描述】:
我已经定义了一个关键道具。仍然反应原生是抛出这个警告: 数组或迭代器中的每个子元素都应该有一个唯一的 key prop
<MapView
style={styles.map}
>
{
locations.map((location)=> {
if (renderArray[wertwert]){
let content;
if (location.isARealTimeGPS) {
content = <View style={styles.marker}/>
} else {
content = <LocationInfoComponent location={location} handleLocationClick={this.handleLocationClick}
locations={locations} infoVisible={infoVisible}
/>
}
wertwert = wertwert+1;
return (
<MapView.Marker
key={JSON.stringify(location.latitude)}
coordinate={location}
>
{content}
</MapView.Marker>
)
} else {
wertwert = wertwert+1;
}
})
}
</MapView>
【问题讨论】:
-
您确定
JSON.stringify(location.latitude)正在返回一个唯一值吗?
标签: javascript reactjs react-native