0

I am using NativeBase for my code.

Hello, I'm wondering if there is a way to iterate through more than one array when creating a dynamic list?

e.g.

<Container>
  <Content>
     <List dataArray={items, items2} renderRow={(data,data2) =>
        <ListItem>
            <Text>{data}</Text>
            <Text note>{data2}</Text>
        </ListItem>
     } />
  </Content>
</Container>

Could this be done? What's the correct syntax because the above doesn't work! Any help would be much appreciated.

rsokz
  • 156
  • 1
  • 9
  • Have you tried dataArray={[items, items2]} – CodAri Apr 26 '17 at 20:38
  • Yes, I did. That messes with the content, not sure exactly what happens. Here's the code: Created to random arrays. Instead of putting 'items2' in the Text note, the entire array is generated into the a second item list. Here's a link to screenshot: http://imgur.com/a/ZbchX – rsokz Apr 27 '17 at 00:48
  • @ludacris3399 The issue you are facing, is added onto our GitHub Issues list. Check [here](https://github.com/GeekyAnts/NativeBase/issues/875) for updates – Supriya Kalghatgi May 25 '17 at 08:25

1 Answers1

0

NativeBase List is using React-Native ListView Component generating Lists. List dataArray prop is passed to ListView dataSource with cloneWithRows.

You can combine your item arrays before those are passed to dataArray.

<List dataArray={ items.concat(items2) } renderRow={(data,data2) => .....
CodAri
  • 333
  • 1
  • 3
  • 16
  • So I want 'data2' to correlate to to 'items2'... Not sure thats what its doing. When I concat, this is what it look like: http://imgur.com/a/7ZftW... the content in my two arrays: `var items = ['Simon Mignolet','Nathaniel Clyne','Dejan Lovren','Mama Sakho']; var items2 = ['Sub1','Sub2','Sub3','Sub4'];`. – rsokz Apr 27 '17 at 20:17