Reputation: 212
so I have this array:
let Reviews = [
{
name: "Tibo Mertens",
review: "Very nice model",
},
{
name: "Quintt Adam",
review: "I like the car",
},
];
And a Flatlist:
<View>
<FlatList
data={Reviews}
renderItem={({ item }) => {
<View>
<Text>{item.name}</Text>
</View>;
}}
></FlatList>
</View>
Where you see {item.name} I want to display the names of the objects in the flatlist. But nothing is showing, the value is undefined. How do I get the right values?
Upvotes: 0
Views: 52
Reputation: 8794
There are a few things wrong with your code.
View
in renderItem
.View
in renderItem
- You should remove that.FlatList
should be self-closing.<View>
<FlatList
data={Reviews}
renderItem={({ item }) =>
<View><Text>{item.name}</Text></View>
}
/>
</View>
To note, the above is an implicit return and is an alternative to the following:
renderItem={({ item }) => {
return <View><Text>{item.name}</Text></View>
}}
Upvotes: 1