React native 按React Native键时从按钮列表中获取键

React native 按React Native键时从按钮列表中获取键,react-native,react-native-flatlist,react-native-sectionlist,React Native,React Native Flatlist,React Native Sectionlist,我显示了一个列表(使用),并希望能够显示他们的关键(即他们的索引)时,他们被点击-但我挣扎着让它和一个MK按钮的工作 任何帮助都将不胜感激。非常感谢 带有onPress的按钮生成器: AllConnectionsItemButton = MKButton.flatButton() .withOnPress( (key) => alert(key)) .build() <SectionList renderItem={({item, index, section}) =&

我显示了一个列表(使用),并希望能够显示他们的关键(即他们的索引)时,他们被点击-但我挣扎着让它和一个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}
/>
部分列表:

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}
/>
(
{item.name}
)}
renderSectionHeader={({section:{title}}})=>(
{title}
)}
sections={this.state.myList}
keyExtractor={(项,索引)=>item+index}
/>