-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Table get stuck in loading state #612
Comments
Sounds like your In your example, you're never actually loading data. For example: return new Promise((resolve, reject) => {
setTimeout(() => {
var newDataFromServer = [];
// This line will only ever assign 0 because `newDataFromServer` is always empty
var newCount = newDataFromServer.length > 0 ? newDataFromServer.length + 1 : 0;
this.setState({remoteRowCount: newCount});
resolve(newDataFromServer);
}, 250);
}); Also, nothing is ever updating the Here's a fork of your Plnkr that works (in the way I imagine you wanting it to): https://plnkr.co/edit/lwiMkw?p=preview |
Thanks for taking the time to review this. Still, in my scenario, let say the button is actually a "filter" and will call a different endpoint on the server. click the button set state to -> 1. |
I'm not sure what your follow-up question is. 😄 What you have described is supported by react-virtualized. I suspect you're not setting/resetting some local state correctly in the case you're describing. It's hard for me to diagnose without seeing your application though. |
I guess I just don't understand why LoadMoreRows is not called in this situation:
|
Reproduce it on Plnkr. |
https://embed.plnkr.co/bgLtSvB8RB5gRhepWfRm/ |
Looks like I have to call it myself because of memoization:
Seems to work Thanks again for the great lib :) |
👍 Glad you got things sorted out. You're welcome! |
Hi, it's me again :( So I made a new plunker with a real world scenario. ScenarioYou have a search bar to search on the server. Steps to reproduce bug:
Expected behavior:
Plunkerhttps://plnkr.co/edit/bgLtSvB8RB5gRhepWfRm?p=preview Additional infos:
PS: Looks like I have the same issue as this guy: #361 (comment) |
I'd actually forgotten that I'd added memoization to that callback back with a4ac8a5. (I haven't used this component in a while.) Some form of memoization is useful in order to prevent However, I can see how the current implementation is problematic. I could try to only cache while a request is in progress- except that I don't require a promise to be returned from So maybe the best thing to do is to provide an API to reset/clear the memoized cache. Thoughts? |
I think most infinite scroll libraries I used, implement a flag ( I think an easy solution would be to provide a public function to |
Edit: It seems that this fix is not working 100% of the time. Edit2:: resetList() {
this._child.resetMemoizer();
this.setState({list: [], rowCount: 0}, () => {
this.setState({rowCount: 1});
});
} Inside InfiniteLoader class: resetMemoizer() {
this._loadMoreRowsMemoizer = createCallbackMemoizer()
} Then, in my code I have:
and: resetList() {
this._child.resetMemoizer() Plunker |
Thank you for the updates! I'll be happy to add a |
9.3.0 was just released. |
Awesome, that was fast. |
Hello all,
I made a table with infinite scrolling.
In my scenario, I have many endpoints that returns empty lists (
[]
).We start with 0 rows, and when to component first load, we set it to 1 row to trigger the infinite load.
[]
(we set state to 0 rows) -> display "No rows" (so far so good)Then we change some filters (click button) and want to call the server for new data.
Here is a plunker to better explain my situation.
https://embed.plnkr.co/bgLtSvB8RB5gRhepWfRm/
Do you guys have any idea what I'm doing wrong ?
Thanks in advance.
The text was updated successfully, but these errors were encountered: