react-native-material-kit icon indicating copy to clipboard operation
react-native-material-kit copied to clipboard

Get key from button list when pressed

Open maxbeech opened this issue 6 years ago • 0 comments

Hi there!

I am displaying a list of Material Kit buttons (using SectionList) and what to be able to display their key (ie. their index) when they are clicked - however am struggling with the getting it working with an MK button.

Any help would be really appreciated. Thanks!

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}
/>

maxbeech avatar Sep 17 '18 10:09 maxbeech