diff --git a/packages/virtual/src/index.tsx b/packages/virtual/src/index.tsx index a5d8886ac..27735db89 100644 --- a/packages/virtual/src/index.tsx +++ b/packages/virtual/src/index.tsx @@ -17,11 +17,7 @@ type VirtualListReturn = [ viewerTop: number; visibleItems: T; }>, - onScroll: ( - e: Event & { - target: DOMElement; - }, - ) => void, + onScroll: (e: Event) => void, ]; /** @@ -61,7 +57,8 @@ export function createVirtualList({ visibleItems: items.slice(getFirstIdx(), getLastIdx()) as unknown as T, }), e => { - setOffset(e.target.scrollTop); + // @ts-expect-error + setOffset(e.target?.scrollTop); }, ]; } @@ -90,10 +87,10 @@ export function VirtualList( props: VirtualListProps, ): JSX.Element { const [virtual, onScroll] = createVirtualList({ - items: props.each, - rootHeight: props.rootHeight, - rowHeight: props.rowHeight, - overscanCount: props.overscanCount, + items: () => props.each, + rootHeight: () => props.rootHeight, + rowHeight: () => props.rowHeight, + overscanCount: () => props.overscanCount || 1, }); return (