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
Property | Description | Type | Default |
---|---|---|---|
target | DOM element or Ref Object | (() => HTMLElement) | HTMLElement | React.RefObject | - |
onEnter | Listen to hover | ()=>void | - |
onLeave | Listening leave hover | ()=>void | - |
Result
Property | Description | Type |
---|---|---|
isHovering | Determine whether the mouse element is in the hover element | boolean |