I have this array which contains objects:
var tmp_array = [
{ headline: \"Test\", text: \"Test text\", send_at: \"test date\" }
];
Now in the
Try forEach method instead of map
:
var WholeNews =[];
tmp_array.forEach(function(news, i){
WholeNews.push(
<View key={i}>
<Text>{news.headline}</Text>
<View>
<Text>{news.text}</Text>
</View>
</View>);
});
And note from where you can get the i
index..
This should work:
WholeNews() {
return tmp_array.map(function(news, i){
return(
<View key={i}>
<Text>{news.headline}</Text>
<View>
<Text>{news.text}</Text>
</View>
</View>
);
});
}
render() {
return(
<View>
{this.WholeNews()}
</View>
)
}