diff --git a/packages/x-data-grid/src/components/virtualization/GridVirtualScrollbar.tsx b/packages/x-data-grid/src/components/virtualization/GridVirtualScrollbar.tsx index 42b3fb00e8c7..ba3534bfbc79 100644 --- a/packages/x-data-grid/src/components/virtualization/GridVirtualScrollbar.tsx +++ b/packages/x-data-grid/src/components/virtualization/GridVirtualScrollbar.tsx @@ -94,7 +94,10 @@ const GridVirtualScrollbar = React.forwardRef { const scroller = apiRef.current.virtualScrollerRef.current!; - const scrollbar = scrollbarRef.current!; + const scrollbar = scrollbarRef.current; + if (!scrollbar) { + return; + } if (scroller[propertyScroll] === lastPosition.current) { return; @@ -114,7 +117,10 @@ const GridVirtualScrollbar = React.forwardRef { const scroller = apiRef.current.virtualScrollerRef.current!; - const scrollbar = scrollbarRef.current!; + const scrollbar = scrollbarRef.current; + if (!scrollbar) { + return; + } if (isLocked.current) { isLocked.current = false;