4

我目前使用 React Native 的 ListView 来显示带有部分标题 ( renderSectionHeader) 的列表:

<ListView
  dataSource={this.state.dataSource}
  renderRow={(rowData) => <JobListDetail firstOccurrence={rowData} />}
  renderSectionHeader={(sectionData, sectionId) => <ListSectionHeader sectionId={sectionId} />}
/>

包含一个对象数组,dataSource键中的部分标题和一个列表项数组作为值,如下所示

{
  Section 1: [{firstName: 'A', lastName: 'B'}, {firstName: 'C', lastName: 'D'}],
  Section 2: [{firstName: 'E', lastName: 'F'}, {firstName: 'G', lastName: 'H'}]
}

我想知道是否可以使用 NativeBase 的List组件实现相同的效果(并且布局看起来更好)。但是,我找不到有关如何传入部分标题的任何信息:

<List dataArray={items} renderRow={(data) =>
    <ListItem>
        <Text>{data}</Text>
    </ListItem>
} />

这可能吗?如果可以,使用它而不是 React Native 有缺点ListView吗?

4

1 回答 1

0

理论上 NativeBaseList应该接受 React NativeListView支持的 props。

部分标题可以使用itemHeader道具呈现:

<ListItem itemHeader>
  <Text>ACTION</Text>
</ListItem>
于 2017-03-30T23:21:35.443 回答