我正在显示Material Kit 按钮的列表(使用SectionList),并希望能够在单击它们时显示它们的键(即它们的索引) - 但是我正在努力让它与 MK 按钮一起工作。
任何帮助将非常感激。万分感谢!
带有 onPress 的按钮生成器:
AllConnectionsItemButton = MKButton.flatButton()
.withOnPress( (key) => alert(key))
.build()
部分列表:
<SectionList
renderItem={({item, index, section}) => (
<AllConnectionsItemButton key={index}>
<Text>{item.name}</Text>
</AllConnectionsItemButton>
)}
renderSectionHeader={({section: {title}}) => (
<View>
<Text>{title}</Text>
</View>
)}
sections={this.state.myList}
keyExtractor={(item, index) => item + index}
/>