diff --git a/packages/x-data-grid/src/hooks/features/virtualization/useGridVirtualScroller.tsx b/packages/x-data-grid/src/hooks/features/virtualization/useGridVirtualScroller.tsx index 499c21a66c40b..1502dfbf4ec61 100644 --- a/packages/x-data-grid/src/hooks/features/virtualization/useGridVirtualScroller.tsx +++ b/packages/x-data-grid/src/hooks/features/virtualization/useGridVirtualScroller.tsx @@ -267,9 +267,14 @@ export const useGridVirtualScroller = () => { ); const triggerUpdateRenderContext = useEventCallback(() => { + const scroller = scrollerRef.current; + if (!scroller) { + return undefined; + } + const newScroll = { - top: scrollerRef.current!.scrollTop, - left: scrollerRef.current!.scrollLeft, + top: scroller.scrollTop, + left: scroller.scrollLeft, }; const dx = newScroll.left - scrollPosition.current.left;