UNPKG

@guruhotel/aura-hooks

Version:

🪝 Hooks library designed by the Guruhotel team for Aura UI

1 lines 448 B
import{useState as e,useEffect as r,useRef as n,useCallback as t}from"react";export function useHover(){const[u,o]=e(!1),v=n(null),s=t((()=>o(!0)),[]),c=t((()=>o(!1)),[]);return r((()=>{if(v.current)return v.current.addEventListener("mouseenter",s),v.current.addEventListener("mouseleave",c),()=>{var e,r;null==(e=v.current)||e.removeEventListener("mouseenter",s),null==(r=v.current)||r.removeEventListener("mouseleave",c)}}),[]),{ref:v,hovered:u}}