Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: changing hasMore before you scroll down doesnt update component #288

Open
x3malmusic opened this issue Jan 4, 2022 · 1 comment
Open

Comments

@x3malmusic
Copy link

so today i had a problem and while i was reserching it, i discover that changing props doesnt update an infinite scroll component. Or it does update but event listeners are still there and they fire loadMore function when it shouldnt.

My situation is that i have two props, first one is total_count and other one is the count of actual items that i receive from the server.
and my implementation of hasMore is looks something like:

hasMore = count < total_count

So on the first render i have 0 < 10 which is true and on the second render when server responded with items i have 10 < 10, which is false. So when i scroll down it invokes loadMore function despite the fact that hasMore is actually false. When i looked onto InfiniteScroll in react devtools, i found that hasMore prop is false. So that's definitely not the problem of my code.

@yuujitaka
Copy link

I have the same problem here, and I had to verify hasMore in loadMore like this:

const loadMore = () => {
    if (!isFetching && hasMore) {
      //....
    }
  };

This seems to work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants