Skip to content

Commit 1faedc8

Browse files
gabrieljablonskidanielbarion
authored andcommitted
fix useEffect() inifinite loop
1 parent bcb2fbb commit 1faedc8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/components/Tooltip/Tooltip.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ const Tooltip = ({
115115

116116
const anchorById = document.querySelector(`[id='${anchorId}']`) as HTMLElement
117117
if (anchorById) {
118-
setActiveAnchor({ current: anchorById })
118+
setActiveAnchor((anchor) =>
119+
anchor.current === anchorById ? anchor : { current: anchorById },
120+
)
119121
elementRefs.add({ current: anchorById })
120122
}
121123

0 commit comments

Comments
 (0)