how to show a list of array data in an object of another array in a flatlist with react native?
this is the list of data below i would like to display in the flatlist
const data = [
{
students: [
{
name: 'crystal',
city: 'town',
number: 1,
},
{
name: 'barbra',
city: 'street',
number: 2,
},
],
},
];
i tried this below but nothing is showing
<FlatList
data={data.students}
renderItem={({ item }) => {
return (
<View>
<View>
<Text style={{ fontSize: 16 }}>{item.name}</Text>
<Text style={{ fontSize: 16 }}>{item.city}</Text>
<Text style={{ fontSize: 16 }}>{item.number}</Text>
</View>
</View>
);
}}
/>
datalooks like an array with a single object inside. Trydata[0].students. Or perhaps get rid of the outer array if it's not needed.