Implement a useHover hook that tracks whether an element is being hovered.
exportdefaultfunction Component() {
const [ref, hovered] = useHover();
return (
<div>
<div ref={ref}>{hovered ? 'Hovered' : 'Not hovered'}</div>
</div>
);
}
Nothing.
The hook returns an array with two elements:
ref prop of the element to track. This has the type (element: T | null) => void, where T extends Elementboolean that indicates whether the element is currently being hovered