Skip to content

Commit cf339b3

Browse files
committed
lint
1 parent d4dcb51 commit cf339b3

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

packages/gamut/src/Tip/InfoTip/index.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,19 @@ export const InfoTip: React.FC<InfoTipProps> = ({
7474
}
7575
};
7676

77-
const handleOutsideClick = (e: MouseEvent) => {
78-
if (
79-
wrapperRef.current &&
80-
(e.target instanceof HTMLElement
81-
? !wrapperRef.current?.contains(e?.target)
82-
: true)
83-
) {
84-
setTipIsHidden(true);
85-
}
86-
};
77+
const handleOutsideClick = useCallback(
78+
(e: MouseEvent) => {
79+
if (
80+
wrapperRef.current &&
81+
(e.target instanceof HTMLElement
82+
? !wrapperRef.current?.contains(e?.target)
83+
: true)
84+
) {
85+
setTipIsHidden(true);
86+
}
87+
},
88+
[setTipIsHidden]
89+
);
8790

8891
const clickHandler = () => {
8992
const currentTipState = !isTipHidden;
@@ -107,7 +110,7 @@ export const InfoTip: React.FC<InfoTipProps> = ({
107110
return () => {
108111
document.removeEventListener('mousedown', handleOutsideClick);
109112
};
110-
});
113+
}, [handleOutsideClick]);
111114

112115
useEffect(() => {
113116
if (!isTipHidden && placement === 'floating') {

0 commit comments

Comments
 (0)