1.0.0 â€ĸ Published 1 year ago

@reactdev/react-use-hover v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

react-use-hover

Detect whether the mouse is hovering an element. The hook returns a ref and a boolean value indicating whether the element with that ref is currently being hovered. Just add the returned ref to any element whose hover state you want to monitor. One potential bug with this method: If you have logic that changes the element that hoverRef is added to then your event listeners will not necessarily get applied to the new element. If you need this functionality then use this alternate version that utilizes a callback ref.

Usage

npm i @reactdev/react-use-hover
import useHover from "@reactdev/react-use-hover";
function App() {
  const [hoverRef, isHovered] = useHover();

  return <div ref={hoverRef}>{isHovered ? "😁" : "☚ī¸"}</div>;
}