Skip to content

Commit

Permalink
resolve linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
max-degterev committed Sep 25, 2024
1 parent c075e55 commit 44bf19a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/@mantine/hooks/src/use-hover/use-hover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ export function useHover<T extends HTMLElement = HTMLDivElement>() {
const onMouseLeave = useCallback(() => setHovered(false), []);

useEffect(() => {
if (!ref.current) return;
ref.current.addEventListener('mouseenter', onMouseEnter);
ref.current.addEventListener('mouseleave', onMouseLeave);
if (ref.current) {
ref.current.addEventListener('mouseenter', onMouseEnter);
ref.current.addEventListener('mouseleave', onMouseLeave);

return () => {
ref.current?.removeEventListener('mouseenter', onMouseEnter);
ref.current?.removeEventListener('mouseleave', onMouseLeave);
};
return () => {
ref.current?.removeEventListener('mouseenter', onMouseEnter);
ref.current?.removeEventListener('mouseleave', onMouseLeave);
};
}

return undefined;
}, [ref.current]);

return { ref, hovered };
Expand Down

0 comments on commit 44bf19a

Please sign in to comment.