From 45dc398377d499e1d567de97ca3ee65ba94547f7 Mon Sep 17 00:00:00 2001 From: Bilal Shafi Date: Tue, 5 Nov 2024 20:18:35 +0500 Subject: [PATCH] [DataGrid] Fix `null` reference error in `GridVirtualScrollbar` (#15009) --- .../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;