我目前使用 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
是否有缺点? ?
最佳答案
理论上 NativeBase 的 List
应该接受 React Native 的 ListView
的 Prop 支持。
部分标题可以用 itemHeader
呈现支柱:
<ListItem itemHeader>
<Text>ACTION</Text>
</ListItem>
关于react-native - 使用分隔符 React Native NativeBase ListView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43129763/