mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-26 21:53:06 +00:00
fix: stabilize virtualizer getItemKey with ref to prevent row remounts during RSC revalidation
This commit is contained in:
parent
452cb396d9
commit
c2229596e4
1 changed files with 4 additions and 2 deletions
|
|
@ -177,6 +177,8 @@ export const CampaignInfiniteTable = <Row,>({
|
|||
const extra = appended.pages.flat().filter((row) => !seedKeys.has(rowKey(row)))
|
||||
return [...rows, ...extra]
|
||||
}, [rows, appended.pages, rowKey])
|
||||
const loadedRowsRef = useRef(loadedRows)
|
||||
loadedRowsRef.current = loadedRows
|
||||
|
||||
useEffect(() => {
|
||||
setScrollElement(rootRef.current?.closest(CAMPAIGN_CONTENT_SCROLL_SELECTOR) ?? null)
|
||||
|
|
@ -259,10 +261,10 @@ export const CampaignInfiniteTable = <Row,>({
|
|||
overscan: 8,
|
||||
getItemKey: useCallback(
|
||||
(index: number) => {
|
||||
const row = loadedRows[index]
|
||||
const row = loadedRowsRef.current[index]
|
||||
return row ? rowKey(row) : `skeleton-${index}`
|
||||
},
|
||||
[loadedRows, rowKey],
|
||||
[rowKey],
|
||||
),
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue