diff --git a/changelogs/upcoming/7534.md b/changelogs/upcoming/7534.md new file mode 100644 index 00000000000..e68482dfd65 --- /dev/null +++ b/changelogs/upcoming/7534.md @@ -0,0 +1,3 @@ +**Bug fixes** + +- Fixed `EuiDataGrid` component to clean up timer from side effect on unmount \ No newline at end of file diff --git a/src/components/datagrid/utils/grid_height_width.ts b/src/components/datagrid/utils/grid_height_width.ts index f7239ac7014..e1479cdb76d 100644 --- a/src/components/datagrid/utils/grid_height_width.ts +++ b/src/components/datagrid/utils/grid_height_width.ts @@ -183,12 +183,14 @@ export const useVirtualizeContainerWidth = ( useEffect(() => { // wait for layout to settle, then measure virtualize container - setTimeout(() => { + const timerId = setTimeout(() => { if (virtualizeContainer?.clientWidth) { const containerWidth = virtualizeContainer.clientWidth; setVirtualizeContainerWidth(containerWidth); } }, 100); + + return () => clearTimeout(timerId); }, [pageSize, virtualizeContainer]); // Use clientWidth of the virtualization container to take scroll bar into account