@ej-hooks/use-hover
v1.0.0
Published
React Hook to detect a hover on an any React Element
Downloads
4
Maintainers
Readme
@ej-hooks/use-hover
React Hook to detect a hover on an any React Element
Installation
yarn
yarn add @ej-hooks/use-hover
npm
npm i @ej-hooks/use-hover
Usage
import React from 'react';
import useHover from '@ej-hooks/use-hover';
function App() {
const onHover = () => console.log('Somebody hovered!');
const makedRef = useHover(onHover);
return <h1 ref={makedRef}>Hello Hooks</h1>;
}
Arguments
| Argument | Type | Description | Required | | -------- | -------- | ------------------------------------------------- | -------- | | onHover | function | Function to be called when the element is hovered | yes |
Return
| Return value | Type | Description | Default value | | ------------ | --------- | --------------------------------------------------------------- | ------------- | | ref | React Ref | A React Ref listening to the hover event, add it to any element | null |