question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[ListView] releases responder to parent

See original GitHub issue

I have a ListView nested inside a View.

<View style={styles.container} {...this._panGesture.panHandlers}>
  <ListView
    ref="list"
    dataSource={this.state.dataSource}
    renderRow={this._renderRow}
    style={styles.list}
  />
</View>

The outer View has a PanResponder. The ListView is not blocking the parent from taking the gesture responder but is releasing control to the parent View on move which causes the ListView to not be scrollable.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:3
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
christopherabouabdocommented, Feb 1, 2016

@jbuffin I ran into this issue today and found that if you overwrite a couple of the responders on the ListView’s ScrollResponder you can convince it to hold on to the gesture. I added a few lines to your componentDidMount function that will tell the ListView to capture all gestures by default and to deny any termination requests unless you’re scrolled to the top of the list. You can swap the logic in scrollResponderHandleTerminationRequest to handle whatever case you need.

componentDidMount() {
  this.setState({
    dataSource: this.state.dataSource.cloneWithRows(new Array(25).fill('hello')),
  });

  // Tell ListView not to give up the gesture so easy
  Object.assign(this.refs.list.getScrollResponder(), {
    scrollResponderHandleStartShouldSetResponder: () => true,
    scrollResponderHandleTerminationRequest: () => {
      // Release the gesture if scroll content is at the top
      return this.refs.list.scrollProperties.offset < 1
    },
  });
},

EDIT: I swapped in scrollResponderHandleStartShouldSetResponder in place of scrollResponderHandleStartShouldSetResponderCapture so you don’t end up eating up all the touch events from child elements in the ListView.

0reactions
mkonicekcommented, Jul 29, 2016

Hi there! This issue is being closed because it has been inactive for a while.

But don’t worry, it will live on with ProductPains! Check out its new home: https://productpains.com/post/react-native/listview-releases-responder-to-parent

ProductPains helps the community prioritize the most important issues thanks to its voting feature. It is easy to use - just login with GitHub. GitHub issues have voting too, nevertheless Product Pains has been very useful in highlighting the top bugs and feature requests: https://productpains.com/product/react-native?tab=top

Also, if this issue is a bug, please consider sending a pull request with a fix. We’re a small team and rely on the community for bug fixes of issues that don’t affect fb apps.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to pass listview onClick events to parent view
I have a listview inside a RelativeLayout. I want any clicks on the listview to call the Relativelayout's onClick listener. How can the...
Read more >
4. Components for Mobile - Learning React Native [Book]
Returning true allows release. View.props.onResponderTerminate. The responder has been taken from the view. It might be taken by other views after a call ......
Read more >
[Solved]-Both the parent and the child components get rendered ...
Coding example for the question Both the parent and the child components get rendered simultaneously in react-native-React Native.
Read more >
Platform Release Notes - PagerDuty Knowledge Base
This change truncates reminder email subject lines to 250 characters or less. This will affect on-call reminders, incident alerts, and add responder requests....
Read more >
Major, candidate, and child cases
To identify major cases in the list view, check the value in the Major case ... case is created and the candidate case...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found