bvaughn / react-window

React components for efficiently rendering large lists and tabular data
https://react-window.now.sh/
MIT License
15.48k stars 778 forks source link

Shifting all items in a list #757

Open szszoke opened 4 months ago

szszoke commented 4 months ago

I am looking at my options for implementing a list that would be used for displaying the last N items of a growing collection. The items would have variable height.

In reality, the collection wouldn't grow and instead old items would be removed to make space for new items once there are N items.

The end result is the same, however: once the collection has grown to N items, I have to call resetAfterIndex(0) every time the collection has been shifted (an old row removed and a new row added).

I haven't actually tried this and the performance I get might be good enough, but still, I was wondering if someone had implemented anything similar with react-window.

I think if I run into performance issues from having to re-measure the item heights so often then my best bet is to keep my own height cache and index that cache in a way that doesn't depend on the item index.