import { MaybeRef , unRef } from '@react-hooks-library/shared' ; import { useEffect , useState } from 'react' ; param target returns export function useHover ( target ) { const [ isHovered , setIsHovered ] = useState ( false ) ; useEffect ( ( ) => { const el = unRef ( target ) ; if ( ! el ) return ; const onMouseEnter = ( ) => setIsHovered ( true ) ; const onMouseLeave = ( ) => setIsHovered ( false ) ; el . addEventListener ( 'mouseenter' , onMouseEnter ) ; el . addEventListener ( 'mouseleave' , onMouseLeave ) ; return ( ) => { el . removeEventListener ( 'mouseenter' , onMouseEnter ) ; el . removeEventListener ( 'mouseleave' , onMouseLeave ) ; } ; } , [ target ] ) ; return isHovered ; }