Replies: 1 comment
|
const renderedIndices = useRef(new Set<number>())
const virtualItems = virtualizer.getVirtualItems()
const newIndices = new Set(virtualItems.map((item) => item.index))
// after render, before the next one:
useEffect(() => {
renderedIndices.current = newIndices
})
// in your row renderer:
{virtualItems.map((item) => {
const isNewlyVisible = !renderedIndices.current.has(item.index)
return isNewlyVisible
? <RowPlaceholder key={item.key} style={...} />
: <ExpensiveRow key={item.key} data={data[item.index]} style={...} />
})}This gives you exactly the granularity you're after, rows already in |
Uh oh!
There was an error while loading. Please reload this page.
Is it possible to display placeholders only for the rows that are not in the view or in the over scan range when scrolling?
Using
isScrollingis a too broad state to be really useful, especially when having table cells that are expensive to render.Looking forward for any suggestion.
Thank you.
All reactions