onEndReached firing multiple times

See original GitHub issue

Describe the bug onEndReached method gets fired multiple times when scrolling to the end of scroll view when trying to fetch next set of data for pagination.

Code:

 return (
    <View style={styles.container}>
      <MasonryList
        contentContainerStyle={styles.bListContainer}
        data={feedActivites}
        keyExtractor={(item) => item.id}
        numColumns={2}
        showsVerticalScrollIndicator={false}
        renderItem={({ item }) => <ActivityCard key={item.id} activity={item} />}
        refreshing={feedFetching}
        onRefresh={() => getInitialFeedActivites()}
        onEndReached={() => {
            console.log('onEndReached Fired!');
            // getNextActivites();
        }}
        onEndReachedThreshold={0.1}
      />
    </View>
  );
}

To Reproduce Steps to reproduce the behavior:

  1. Add data to data array
  2. add onEndReached Method
  3. Scroll down to end of List
  4. onEndReached Method gets called in rapid succession multiple times

Expected behavior Should only fire one time when reaching end of list

Screenshots If applicable, add screenshots to help explain your problem.

Screen Shot 2021-07-11 at 12 14 27 PM

Desktop (please complete the following information):

  • OS: Mac OS Big Sir
  • Browser: Chrome
  • Version: 91

Smartphone (please complete the following information):

  • Device: iPhone 12
  • OS: iOS 14.5

Additional context Add any other context about the problem here.

Issue Analytics

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

github_iconTop GitHub Comments

4reactions
itajenglishcommented, Jul 22, 2021

This solution worked for me. https://stackoverflow.com/a/47940952/1065877

1reaction
hyochancommented, Aug 11, 2021

I am not sure why I can’t reproduce this on my side. I’ll see how I can handle this internally when I can reproduce this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

FlatList onEndReached being called multiple times
The reason of triggering onEndReached multiple times is because you have not set initialNumToRender properly. onEndReached is triggered in ...
Read more >
onEndReached called many many times · Issue #23060
Once you scroll Flatlist to the bottom, call onEndReached , then props changed, it call once again!
Read more >
iOS : FlatList onEndReached being called multiple times
iOS : FlatList onEndReached being called multiple times [ Gift : Animated Search Engine : https://bit.ly/AnimSearch ] iOS : FlatList ...
Read more >
FlatList onEndReached being called multiple times-React ...
Coding example for the question FlatList onEndReached being called multiple times-React Native.
Read more >
flatlist onendreached not working
react-native-flatlist onendreached called multiple times ... Will never get fired, or some times it will be called only first time when list is...
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