I have this array which contains objects:
var tmp_array = [
{ headline: "Test", text: "Test text", send_at: "test date" }
];
Now in the web react environment I was able to map through this array and return its values to a variable which can then be rendered.
So I used the same approach:
var i = -1;
var WholeNews = tmp_array.map(function(news){
i++;
return(
<View key={i}>
<Text>{news.headline}</Text>
<View>
<Text>{news.text}</Text>
</View>
</View>);
});
After the mapping has finished it should be rendered as following:
return(
<View>
{WholeNews}
</View>
);
Unfortunately I receive a warning in my iOS Simulator which says:
Objects are not valid as a React child(found: object with keys {WholeNews}). If you meant to render a collection of children, use an array instead or wrap the object using createFrament(object) from the React-addons.
I am not sure whether I am missing out something completely or react native simply doesn't support a mapping through an array as in my example.
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>
)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With