Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ScrollView property 'onScroll' only fires once

I'm trying to get this extremely simple React Native (Expo) Code to work:

Inside my App.js:

return (
  <ScrollView
    scrollEventThrottle={16}
    onScroll={console.log("Scrolled")}>
    <Text style={{fontSize: 30}}>
      ...
    </Text>
  </ScrollView>
)

It seems as if onScroll would only be fired once when I'm first starting the App, but is not responding to actual scrolling. Any ideas on what could be blocking it?

(using Expo version 3.17.18)

like image 243
maxvw Avatar asked Dec 17 '25 10:12

maxvw


1 Answers

I'm guessing the way that the onScroll is written could be causing it to never trigger it more than once. Please try the following code (I would also recommend having an scrollEventThrottle of 400 or so, 16 will be triggered far too many times, but I wouldn't say that's the root of the current issue):

 return (
  <ScrollView
    scrollEventThrottle={16}
    onScroll={({nativeEvent}) => {console.log("Scrolled")}}>
    <Text style={{fontSize: 30}}>
      ...
    </Text>
  </ScrollView>
)
like image 182
Gabcvit Avatar answered Dec 20 '25 00:12

Gabcvit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!