question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[InfiniteLoader] reloading any rows in the current visible range if necessary is difficult, should be easier

See original GitHub issue

https://codesandbox.io/s/m41ln6k178

Repro steps:

  1. Click the “Fake More Recent Item” button
  2. A “Loading…” row will appear at the top of the list
  3. Wait a moment. InfiniteLoader should have loaded the content for row 0 already, but it fails to do so
  4. Scroll a bit -> InfiniteLoader will then load the content for row 0

I have an infinite list sorted by most recent and I want to make the list load newer items at the top when I get an event that new items have been created.

I’m trying to accomplish this by doing the following:

  • push my data down one row
  • ensure isRowLoaded(0) will now return false
  • call InfiniteLoader.resetLoadMoreRowsCache()
  • call List.forceUpdateGrid()

But Grid’s memoization of onRowsRendered prevents it from calling InfiniteLoader.onRowsRendered, so InfiniteLoader never even rechecks if row 0 is loaded until I scroll around. All of this memoization is one big headache.

UPDATE: I worked around this by calling the onRowsRendered passed to my child function with ({startIndex: 0, stopIndex: 0}). (This of course only works after calling resetLoadMoreRowsCache(). This took me a while to figure out though and I think it should be easier for developers. (At the very least, the memoiziation in InfiniteLoader seems totally pointless)

IMHO if Grid re-renders the current rows (due to forceUpdate, shallow equal prop changes, etc.), it should call onRowsRendered again, even if it passes the same range as the previous call.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:5
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
jedwards1211commented, Nov 17, 2019

@nodejh @skeithyip in case you guys are interested, here’s what I’m using now instead of InfiniteLoader: https://gist.github.com/jedwards1211/684500774eb2ff76dbb21bb9d9500716 Not like I can guarantee there are no bugs in this, but it seems to work pretty well so far.

I kept it super simple: it only keeps one contiguous range of rows in memory, and only fetches one batch of more rows at a time.

Since my infinite lists are all based upon Relay-style connections in GraphQL, I just made this hook do the querying directly in response to scrolling. It’s even got some slick code that analyzes the query AST to automatically figure out which field is the connection and what the pagination variables are 😃

1reaction
jedwards1211commented, Nov 14, 2019

Since I will only ever have a contiguous loaded range of rows and never plan to evict a row from the middle of the loaded rows, I will probably just write my own alternative to InfiniteLoader that keeps track of the loaded range itself.

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-virtualized InfiniteLoader/List - working example using ...
It's not clear whether the rowCount property is intended to represent the current state of loaded rows (the number of rows in a...
Read more >
React table horizontal scroll - Caritas Castellaneta
First, we will create a react application using the create-react-app package. To make the cap visible when scrolling, fix the top row of...
Read more >
Scrollable Grid with JiT Loading – Part 3: React Table + React ...
Rendering the correct data gets easier when React Table transforms the data. Whenever InfiniteLoader fetches new row data, the data can be ...
Read more >
Create an infinite loading list with React and GraphQL
It saves users from a full page load. It also provides better user experience in mobile applications. Infinite loading list of persons *We...
Read more >
React performance optimization: Windowing vs. component ...
When optimizing the performance of large lists of data in React, ... But what if we don't necessarily need to render all the...
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