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.

FlatList onScroll event

See original GitHub issue

Hello All, I have an issue that when I use FlatList to create horizontal scroll I need to listen for OnScroll event. When I mapping Native event with event() I receive error that I need to add Animated prefix to FlatList to use event(), however then I receive error: Invariant violation: element type is invalid: expect a string or class/function but got undefined.

Does FlatList is working in reanimated? When I changed FlatList to ScrollView it worked with Animated.ScrollView . Do we have any working example with OnScroll and FlatList?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
terrysahaidakcommented, Dec 4, 2019

Hi @davx1992. react-native-reanimated does not provide an Animated FlatList, but it provides the ScrollView component, so you can use renderScrollComponent to provide an Animated ScrollView to your FlatList:

<FlatList 
  {...props}
  renderScrollComponent={(props) => <ScrollView {...props} onScroll={(evt) => {
    console.log(evt);
  }} />}
/>
3reactions
Daavidaviidcommented, Jan 24, 2020

I can’t make it works, it’s like the renderScrollComponent prop is not called.

Read more comments on GitHub >

github_iconTop Results From Across the Web

react native - How to know the state of scroll in FlatList?
there is onScroll mothed,but it only run when Scrolling. I want to listen scroll start and end,how can i do ? I also...
Read more >
FlatList
A performant interface for rendering basic, flat lists, supporting the most handy features:
Read more >
How to find out FlatList scroll direction - mobiledevtutorials
when onScroll the event fired, we need to compare contentOffset value with the previous value. then also we need to know if it's...
Read more >
How to find out FlatList scroll direction | by Nazır Doğan
when onScroll the event fired, we need to compare contentOffset the value with the previous value. then also we need to know if...
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