From 07329427bced7047e1d07616938ce3de9f15ab70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Ign=C3=A1cio=20Fontoura=20Solla?= Date: Thu, 6 Aug 2026 00:48:10 -0300 Subject: [PATCH] fix: stabilize virtualizer options to prevent measureElement ref changes that interrupt server actions --- .../campaign/shared/CampaignInfiniteTable.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/campaign/shared/CampaignInfiniteTable.tsx b/src/components/campaign/shared/CampaignInfiniteTable.tsx index 26ef138a..e739bb09 100644 --- a/src/components/campaign/shared/CampaignInfiniteTable.tsx +++ b/src/components/campaign/shared/CampaignInfiniteTable.tsx @@ -254,13 +254,16 @@ export const CampaignInfiniteTable = ({ const virtualizer = useVirtualizer({ count: itemCount, - estimateSize: () => ESTIMATED_ROW_HEIGHT, - getScrollElement: () => scrollElement, + estimateSize: useCallback(() => ESTIMATED_ROW_HEIGHT, []), + getScrollElement: useCallback(() => scrollElement, [scrollElement]), overscan: 8, - getItemKey: (index) => { - const row = loadedRows[index] - return row ? rowKey(row) : `skeleton-${index}` - }, + getItemKey: useCallback( + (index: number) => { + const row = loadedRows[index] + return row ? rowKey(row) : `skeleton-${index}` + }, + [loadedRows, rowKey], + ), }) const virtualItems = virtualizer.getVirtualItems()