react-native-alphabetlistview icon indicating copy to clipboard operation
react-native-alphabetlistview copied to clipboard

onCellSelect callbak is not working

Open codalsrai opened this issue 7 years ago • 4 comments

  • Working with RN 0.36.1, all functionality is working great except onCellSelect callback is not working, I want to perform a certain task if the user is selecting any cell, here is the code snippet : <AlphabetListView data={this.state.data} cell={Cell} cellHeight={30} sectionListItem={SectionItem} sectionHeader={SectionHeader} sectionHeaderHeight={28.5} onCellSelect={() => alert('Hello World')} Any help would be appreciated.

codalsrai avatar Nov 09 '17 06:11 codalsrai

For the same problem, there is no solution to the problem.

xvbo avatar Mar 22 '18 03:03 xvbo

I do have same problem, i used cellProps to pass method to the CellComponent

cellProps={{onCellSelect: this.someFunction}}

jankowskip avatar Jul 16 '18 14:07 jankowskip

same problem . I use render Function return the content instead of CellComponent.

elizond0 avatar Jul 17 '18 07:07 elizond0

hello, you can refer to this example 👌

Example

class Cell extends Component {
  render() {
    return (
      <TouchableHighlight onPress={() => this.props.onSelect(this.props.item)}>
                <View style={{ height: 30 }}>
                    <Text>{this.props.item}</Text>
                </View>
       </TouchableHighlight>
    );
  }
}
//...
class MyComponent extends Component {
  someFunction(value) {
       console.log(value)
  }
  render() {
    return (
      <AlphabetListView
        data={this.state.data}
        cell={Cell}
        cellHeight={30}
        sectionListItem={SectionItem}
        sectionHeader={SectionHeader}
        sectionHeaderHeight={22.5}
        onCellSelect={(value) => this.someFunction(value)}  //<=  onCellSelect()
      />
    );
  }
}

yyd1142 avatar Oct 29 '18 09:10 yyd1142