Skip to content

Latest commit

Β 

History

History
20 lines (13 loc) Β· 413 Bytes

File metadata and controls

20 lines (13 loc) Β· 413 Bytes

🌭 useHover

Know when the mouse if hovering over an element

Returns

  • hoverRef: Ref: add this to the desired hover element
  • isHovered: Bool: Whether or not the mouse is currently hovering over element

Usage

import { useHover } from "react-recipes";

function App() {
  const [hoverRef, isHovered] = useHover();

  return <div ref={hoverRef}>{isHovered ? "😁" : "☹️"}</div>;
}