最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - react native flatlist with several arrays of data - Stack Overflow

programmeradmin1浏览0评论

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 badges
Add a ment  | 

1 Answer 1

Reset to default 3

You 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>
发布评论

评论列表(0)

  1. 暂无评论