VizTooltip: Fix memory leak (#106907)

VizTooltip: Fix memory leak
This commit is contained in:
Bogdan Matei
2025-06-19 11:47:03 +03:00
committed by GitHub
parent 041fadce06
commit 2b21bdf4e1
@@ -144,6 +144,8 @@ export const TooltipPlugin2 = ({
getLinksRef.current = getDataLinks;
useLayoutEffect(() => {
sizeRef.current?.observer.disconnect();
sizeRef.current = {
width: 0,
height: 0,
@@ -646,6 +648,8 @@ export const TooltipPlugin2 = ({
window.addEventListener('scroll', onscroll, true);
return () => {
sizeRef.current?.observer.disconnect();
window.removeEventListener('resize', updateWinSize);
window.removeEventListener('scroll', onscroll, true);
@@ -659,6 +663,7 @@ export const TooltipPlugin2 = ({
const size = sizeRef.current!;
if (domRef.current != null) {
size.observer.disconnect();
size.observer.observe(domRef.current);
// since the above observer is attached after container is in DOM, we need to manually update sizeRef