A hook that return a state referred to whether a element presented by the ref param is hovering by mouse.
import React, { useRef } from 'react'
import { useHover } from '@vergiss/chooks';
export default () => {
const ref = useRef(null);
const isHovering = useHover(ref);
return (
<div ref={ref}>
{ isHovering ? 'yes' : 'no' }
</div>
)
}
const isHovering = useHover(
ref: React.RefObject<HTMLElement>
)
Property |
Description |
Type |
Default |
ref |
Necessary, a ref object referred to an element |
React.RefObject |
- |
Property |
Description |
Type |
isHovering |
Hovering status |
Boolean |