I'm trying to get an object described at the following endpoint : https://api.cosmicjs.com/v1/67302ce0-7681-11e9-8193-4bd8888ec129/objects?pretty=true&hide_metafields=true
As you will notice there is a _id field with a unique identifier.
So why do i get :
"Warning: Encountered two children with the same key,
:
. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted — the behavior is unsupported and could change in a future version."
Here is my FlatList render :
render() {
if(this.props.dataToDisplay.objects){
console.log(typeof(this.props.dataToDisplay.objects))
console.log(this.props.dataToDisplay.objects)
this.props.dataToDisplay.objects.forEach((item)=>{
console.log(item)
})
return (
<View style={[{backgroundColor: this.state.backgroundColor},styles.container]}>
<FlatList
data={this.props.dataToDisplay.objects}
keyExtractor={(item, index)=>{item._id.toString()}}
renderItem={({item})=>{
<Text id={item._id}>{item.title}</Text>
}}
/>
</View>
);
}
else {
return (
<View style={[{backgroundColor:
this.state.backgroundColor},styles.container]}>
<Text>Loading elements.</Text>
</View>
);
}
}
}
Could there be a problem with the keyExtractor ? I tried with keyExtractor={(item, index)=>{item._id}} with no results...
Thanks for your time.