Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I detect when FlatList has rendered all items and actually scrolled to bottom?

I'm passing a very long array into a FlatList.

FlatList dynamically loads more content as you reach the bottom.

I have a ListFooterComponent that indicates whether the user is about to see more data.

How can I know when the FlatList has truly rendered all items and therefore has reached actual bottom of scroll? Then this footer component will show something like "You're at the end of the list!"

like image 355
ericjam Avatar asked Sep 04 '18 15:09

ericjam


Video Answer


1 Answers

FlatList component has a callback function that is called when the list reaches the end or the specified threshold.

<FlatList
    ...
   onEndReached={() => {console.log('list ended');}}
/>

FlatList - onEndReached

like image 181
Pedro Simão Avatar answered Sep 22 '22 22:09

Pedro Simão