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

Set hasMore to "false" doesn't necessarily detaching the event listeners #44

Open
jonathankurniadi opened this issue Jan 26, 2017 · 7 comments · May be fixed by #142
Open

Set hasMore to "false" doesn't necessarily detaching the event listeners #44

jonathankurniadi opened this issue Jan 26, 2017 · 7 comments · May be fixed by #142
Labels

Comments

@jonathankurniadi
Copy link

Setting hasMore to "false" from another function that is not triggered by the callback doesn't remove the event listeners. Is this intentional?

@danbovey
Copy link
Owner

danbovey commented Jan 26, 2017

On Line 86 we detach the event listener and call loadMore, this is where the logic for hasMore is updated by you from an XHR response or similar. Then if the component updates it attaches the event listener, only if hasMore is true.

But I suppose your question is, what would happen if you changed the hasMore prop outside of this process? It wouldn't detach until the above process is made again 😕

I'll see if we can make the same check made by the attach method in scrollListener as well.

if(!this.props.hasMore) {
    return;
}

@jonathankurniadi
Copy link
Author

Thanks for the answer and explanation.

But I suppose your question is, what would happen if you changed the hasMore prop outside of this process?

Yes, that's exactly what I meant. This makes it troublesome if say, I simply want to make a button to attach/detach the event listeners. The doc could be clearer as well, as it states that the event listeners are removed if hasMore is false.

@danbovey danbovey added the bug label Apr 11, 2017
@danbovey
Copy link
Owner

It probably is, I'm swamped with uni work right now so I haven't had a chance to test it.

@dantzchan
Copy link

dantzchan@506138f

This kinda works, I check hasMore on componentWillReceiveProps and detachScrollListener if hasMore is false.

@AliasT
Copy link

AliasT commented Dec 11, 2017

this component has a lot of bugs 🤨🤨

@metal03326
Copy link

I have the same issue, with an ordinary scenario - I have two "tabs" (basically buttons) that fetch data and display it in an infinite scrolling. First (default) tab doesn't have more items (most of the time), but second tab has more items (archived from first tab). When switching from first to second I set hasMore to true and it works. But when switching back to first tab I set hasMore back to false and it still tries to make request to the server for more data.

PierreGUI added a commit to PierreGUI/react-infinite-scroller that referenced this issue Mar 8, 2018
PierreGUI added a commit to PierreGUI/react-infinite-scroller that referenced this issue Mar 8, 2018
PierreGUI added a commit to PierreGUI/react-infinite-scroller that referenced this issue Mar 8, 2018
@PierreGUI PierreGUI linked a pull request Mar 8, 2018 that will close this issue
@DanielSundberg
Copy link

I get the same problem, any plans on merging pull requests that might fix the problem and release a new version?

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

Successfully merging a pull request may close this issue.

6 participants