Skip to content

Commit f49fe16

Browse files
gabrieljablonskiGabriel Jablonski
authored andcommitted
fix: only invoke callbacks when show changes
1 parent 20e2c09 commit f49fe16

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/components/Tooltip/Tooltip.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ const Tooltip = ({
4141
const tooltipHideDelayTimerRef = useRef<NodeJS.Timeout | null>(null)
4242
const [inlineStyles, setInlineStyles] = useState({})
4343
const [inlineArrowStyles, setInlineArrowStyles] = useState({})
44-
const [show, setShow] = useState<boolean>(false)
44+
const [show, setShow] = useState(false)
45+
const wasShowing = useRef(false)
4546
const [calculatingPosition, setCalculatingPosition] = useState(false)
4647
const lastFloatPosition = useRef<IPosition | null>(null)
4748
const { anchorRefs, setActiveAnchor: setProviderActiveAnchor } = useTooltip()(id)
@@ -56,8 +57,11 @@ const Tooltip = ({
5657
}
5758
}
5859

59-
// Callbacks
6060
useEffect(() => {
61+
if (show === wasShowing.current) {
62+
return
63+
}
64+
wasShowing.current = show
6165
if (show) {
6266
afterShow?.()
6367
} else {

0 commit comments

Comments
 (0)