Search code examples
react-nativereact-native-listviewreact-native-scrollview

ScrollView PullDown


I am trying to build a component to detect a pulldown on a scrollview. Pulldown being when you try to refresh facebook or twitter feeds.

So my approach was trying to use the onScroll method to detect the changes from scroll view.

onScroll={this.handleScroll}

handleScroll(event) {
 console.log(event.nativeEvent.contentOffset.y);
}

However, what I found is when you are scrolling downward (like you are scrolling through a facebook or twitter feed), it will give you the value of the offset. I then tried to emulate the 'pulldown' behavior where I would scroll in the opposite direction. The difficulty is when the scroll view reaches 0, I can't detect any decrease in scroll. Does that make sense? Basically how I can detect a pulldown when the scroll view is at 0.


Solution

  • You can use RefreshControl to achieve this