From aa7f9847f2ff601ce45bfa2f58b695932a9ab9b6 Mon Sep 17 00:00:00 2001 From: Andrew Cherniavskii Date: Tue, 26 Nov 2024 20:31:18 +0100 Subject: [PATCH] [DataGrid] Clear timers on unmount (#15620) --- .../src/components/toolbar/GridToolbarQuickFilter.tsx | 1 + .../src/hooks/features/dimensions/useGridDimensions.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/x-data-grid/src/components/toolbar/GridToolbarQuickFilter.tsx b/packages/x-data-grid/src/components/toolbar/GridToolbarQuickFilter.tsx index a323c08b20eb..231649853ab3 100644 --- a/packages/x-data-grid/src/components/toolbar/GridToolbarQuickFilter.tsx +++ b/packages/x-data-grid/src/components/toolbar/GridToolbarQuickFilter.tsx @@ -124,6 +124,7 @@ function GridToolbarQuickFilter(props: GridToolbarQuickFilterProps) { () => debounce(updateSearchValue, debounceMs), [updateSearchValue, debounceMs], ); + React.useEffect(() => debouncedUpdateSearchValue.clear, [debouncedUpdateSearchValue]); const handleSearchValueChange = React.useCallback( (event: React.ChangeEvent) => { diff --git a/packages/x-data-grid/src/hooks/features/dimensions/useGridDimensions.ts b/packages/x-data-grid/src/hooks/features/dimensions/useGridDimensions.ts index a24d44f935d7..dae588d1d1bd 100644 --- a/packages/x-data-grid/src/hooks/features/dimensions/useGridDimensions.ts +++ b/packages/x-data-grid/src/hooks/features/dimensions/useGridDimensions.ts @@ -124,6 +124,7 @@ export function useGridDimensions( () => throttle(setSavedSize, props.resizeThrottleMs), [props.resizeThrottleMs], ); + React.useEffect(() => debouncedSetSavedSize.clear, [debouncedSetSavedSize]); const getRootDimensions = () => apiRef.current.state.dimensions;