From f28a5241fb61e89fb176367024602fbd68f31cce Mon Sep 17 00:00:00 2001 From: wiedld Date: Wed, 6 Jul 2022 14:41:20 -0700 Subject: [PATCH] fix(4882): reduce ResizerObserver looping even further --- src/visualization/types/SimpleTable/PagedTable.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/visualization/types/SimpleTable/PagedTable.tsx b/src/visualization/types/SimpleTable/PagedTable.tsx index 7319437f60..c1d8f4fada 100644 --- a/src/visualization/types/SimpleTable/PagedTable.tsx +++ b/src/visualization/types/SimpleTable/PagedTable.tsx @@ -239,13 +239,14 @@ const PagedTable: FC = ({result, properties}) => { } let timeout + let animationFrameID const resizer = new ResizeObserver(entries => { if (timeout) { clearTimeout(timeout) } timeout = setTimeout(() => { - requestAnimationFrame(() => { + animationFrameID = requestAnimationFrame(() => { setHeight(entries[0].contentRect.height) }) }, 200) @@ -263,6 +264,7 @@ const PagedTable: FC = ({result, properties}) => { return () => { resizer.disconnect() + cancelAnimationFrame(animationFrameID) if (timeout) { clearTimeout(timeout) }