From b35531bbaf5fd855d6fcedf3abcddb62180beabe Mon Sep 17 00:00:00 2001 From: Damian Pieczynski Date: Fri, 23 Aug 2024 13:26:05 +0200 Subject: [PATCH] fix: getItemKey when element is missing from list --- packages/virtual-core/src/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/virtual-core/src/index.ts b/packages/virtual-core/src/index.ts index c3bec65b..42d0b791 100644 --- a/packages/virtual-core/src/index.ts +++ b/packages/virtual-core/src/index.ts @@ -727,8 +727,11 @@ export class Virtualizer< entry: ResizeObserverEntry | undefined, ) => { const index = this.indexFromElement(node) - const key = this.options.getItemKey(index) - + const item = this.measurementsCache[index] + if (!item) { + return + } + const key = item.key const prevNode = this.elementsCache.get(key) if (prevNode !== node) {