From 132f758c899ea495de8badd1aa76746e0e923d51 Mon Sep 17 00:00:00 2001 From: Bilal Shafi Date: Tue, 5 Nov 2024 23:09:43 +0500 Subject: [PATCH] [DataGrid] Fix `null` reference error in `GridVirtualScrollbar` (#15009) (#15289) --- .../components/virtualization/GridVirtualScrollbar.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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;