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.

onScroll not triggering react native android

See original GitHub issue

Hi,

I added onScroll event to RecyclerListView to implement collapsible navbar. Buth the OnScroll prop is not triggering. Below is the code

<RecyclerListView
         layoutProvider={this._layoutProvider} 
         dataProvider={this.state.dataProvider} 
         rowRenderer={this._rowRenderer} 
         onEndReached={() => this.handleLoadMore()}
         onEndReachedThreshold={0.1}
         renderFooter={this.renderFooter}
         refreshControl={<RefreshControl
         refreshing={this.state.refreshing}
         onRefresh={this._onRefresh.bind(this)}          
         showsVerticalScrollIndicator={false}  
         contentContainerStyle={{paddingTop: NAVBAR_HEIGHT}}         
         onscroll={Animated.event(
          [{nativeEvent: {contentOffset: {y: this.scroll}}}],
          {useNativeDriver: true},
)}
 
       />

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8

github_iconTop GitHub Comments

3reactions
naqvitalhacommented, Apr 26, 2018

onScroll gets overridden by RLV internally. If you look at the contract that @AbdallaMohamed mentioned you cannot pass an Animated.event value. You however can extend a ScrollView on your own to achieve this. Look at the following:

class ExtendedScrollView extends BaseScrollView {
     render() {
        return <ScrollView onScroll={Animated.event([this.props.animatedEvent], {listener: this.props.onScroll}} />
     }
}
//While creating RLV
<RecyclerListView {...yourProps} externalScrollView={ExtendedScrollView} animatedEvent={{nativeEvent: {contentOffset: {y: this.scroll}}}} />

This should work. Try it.

1reaction
pijuszcommented, Aug 28, 2019

Hi, I have created collapsible header with these examples using react-native standard Animated library. I want to switch to react-native-reanimated, but I’m facing a problem, that onEndReached is no longer triggering. My guess there is a conflict with reanimated’s Animated.ScrollView, any tips in fixing/debugging this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

ReactNative ScrollView onScroll works fine for IOS but for ...
ScollView to behave like a bottomSheet in Reactnative by using onScroll function in ... But for Android it is not event triggering onScroll....
Read more >
ScrollView - React Native
Component that wraps platform ScrollView while providing integration with touch locking "responder" system.
Read more >
Common bugs in React Native ScrollView and how to fix them
Correctly using onScroll and tracking scroll position may be a tricky task due to performance reasons. This is why it's always important to ......
Read more >
React onScroll example - CodePen
This is a demonstration of how to get onScroll to work with a React Component. The div that I've created gets the scrollTop...
Read more >
useAnimatedScrollHandler | React Native Reanimated
event [object] - event object carrying the information about the scroll. The payload can differ depending on the type of the event (...
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 Hackernoon Post

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