Search code examples
javascriptreactjsreact-nativereact-native-listview

React-native : How to pass parameter to gesture responder callback


I have a listview with rows being rendered by:

   <ListView
    dataSource={_this.state.dataSource}
    renderRow={_this.renderPost}

    renderPost(post) {
      return (
      <View ref="thisRowView"
        style={[MainList_styles.post]}
        onResponderMove={this.setPosition}
        onResponderRelease={this.resetPosition}
        onStartShouldSetResponder={this._onStartShouldSetResponder}
        onMoveShouldSetResponder={this._onMoveShouldSetResponder}
       > 
  ........
  resetPosition: function(var) {

On swipe stop, ie for callback resetPosition, I want to know which row was clicked. I see that if I change it to:

    onResponderRelease={() => _this.resetPosition(post)}

I get the post in the callback but then dont get e, the event at all. How do I do both ?


Solution

  • You can modify your method by adding the event in its parameters :

    onResponderRelease={(e) => this.resetPosition(e, post)}