From c2229596e4d6b126ea38776f56964a1a65702920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Ign=C3=A1cio=20Fontoura=20Solla?= Date: Thu, 6 Aug 2026 01:03:33 -0300 Subject: [PATCH] fix: stabilize virtualizer getItemKey with ref to prevent row remounts during RSC revalidation --- src/components/campaign/shared/CampaignInfiniteTable.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/campaign/shared/CampaignInfiniteTable.tsx b/src/components/campaign/shared/CampaignInfiniteTable.tsx index e739bb09..cc5875f6 100644 --- a/src/components/campaign/shared/CampaignInfiniteTable.tsx +++ b/src/components/campaign/shared/CampaignInfiniteTable.tsx @@ -177,6 +177,8 @@ export const CampaignInfiniteTable = ({ 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 = ({ overscan: 8, getItemKey: useCallback( (index: number) => { - const row = loadedRows[index] + const row = loadedRowsRef.current[index] return row ? rowKey(row) : `skeleton-${index}` }, - [loadedRows, rowKey], + [rowKey], ), })