useHover

React UI sensor hooks that track if some element is being hovered by a mouse.

API is consistent with ahooks.

Examples

Basic Uagge

Pass in DOM element

API

const isHovering = useHover(target, {
  onEnter,
  onLeave,
});

Params

PropertyDescriptionTypeDefault
targetDOM element or Ref Object(() => HTMLElement) | HTMLElement | React.RefObject-
onEnterListen to hover()=>void-
onLeaveListening leave hover()=>void-

Result

PropertyDescriptionType
isHoveringDetermine whether the mouse element is in the hover elementboolean

最近更新: