我目前使用 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
吗?