From f0c523fc344f5186c2629727bc4fa26d807b6967 Mon Sep 17 00:00:00 2001 From: MarcosPierasNL <pieras.marcos@gmail.com> Date: Thu, 11 Jul 2024 12:20:54 +0200 Subject: [PATCH] fix: refactor: memoize children ref to prevent recreating virtual elements every update --- libs/shared/lib/components/tooltip/Tooltip.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/shared/lib/components/tooltip/Tooltip.tsx b/libs/shared/lib/components/tooltip/Tooltip.tsx index 33c54848e..95c792f62 100644 --- a/libs/shared/lib/components/tooltip/Tooltip.tsx +++ b/libs/shared/lib/components/tooltip/Tooltip.tsx @@ -129,9 +129,9 @@ export const TooltipTrigger = React.forwardRef<HTMLElement, React.HTMLProps<HTML const context = useTooltipContext(); const childrenRef = React.useMemo(() => { if (children == null) { - return null; + return React.createElement('div').ref; } else { - return (children as any).ref; + return (children as React.ReactElement).ref; } }, [children]); -- GitLab