DEMO
Not Hovered
useHover
Detect if a dom element is hovered.
Usage
import { useRef } from 'react'
import { useHover } from '@react-hooks-library/core'
export function Demo() {
const ref = useRef<HTMLDivElement | null>(null)
const isHovered = useHover(ref)
return (
<div ref={ref}>
{isHovered ? 'Hovered' : 'Not Hovered'}
</div>
)
}
Type Declarations
/**
*
* Detect if a dom element is hovered
*
* @param target - The element to listen to
* @returns
*/
declare function useHover(target: MaybeRef<EventTarget | null>): boolean;