I'M new to RN and need some help I have an object like
{title:"title",price:"price",subtitle:"subtitle"}
And I'd like to use 2 values at flatlist, like here -
<FlatList
data={this.state.data}
renderItem={({ item }) => (
<ListItem
title={`${item.name.first} ${item.name.last}`}
subtitle={item.email}
/>
)}
/>
</List>
But in this example wasn't show structure of data so I'm confused what should I do. Please help me to solve it! At the end (render) I need a ListItem this view -
(title) (price)
Or I should better use native-base, but the same questions about 2 value, passing to list item
I'M new to RN and need some help I have an object like
{title:"title",price:"price",subtitle:"subtitle"}
And I'd like to use 2 values at flatlist, like here -
<FlatList
data={this.state.data}
renderItem={({ item }) => (
<ListItem
title={`${item.name.first} ${item.name.last}`}
subtitle={item.email}
/>
)}
/>
</List>
But in this example wasn't show structure of data so I'm confused what should I do. Please help me to solve it! At the end (render) I need a ListItem this view -
(title) (price)
Or I should better use native-base, but the same questions about 2 value, passing to list item
Share edited Aug 2, 2017 at 23:56 nastassia asked Aug 2, 2017 at 23:41 nastassianastassia 8972 gold badges15 silver badges33 bronze badges1 Answer
Reset to default 3You have to pass an array into the data property, then you can do:
<FlatList
data={this.state.data}
renderItem={({ item }) => ( //this part will iterate over every item in the array and return a listItem
<ListItem
key={item.id}
title={item.title}
price={item.price}
/>
)}
/>
</List>