mirror of
https://github.com/streamich/react-use.git
synced 2026-01-25 14:17:16 +00:00
26 lines
397 B
Markdown
26 lines
397 B
Markdown
# `useHover`
|
|
|
|
React sensor hook that tracks size of some HTML element.
|
|
|
|
|
|
## Usage
|
|
|
|
```jsx
|
|
import {useHover} from 'react-use';
|
|
|
|
const Demo = () => {
|
|
const element = (hovered) =>
|
|
<div>
|
|
Hover me! {hovered && 'Thanks!'}
|
|
</div>;
|
|
const [hoverable, hovered] = useHover(element);
|
|
|
|
return (
|
|
<div>
|
|
{hoverable}
|
|
<div>{hovered ? 'HOVERED' : ''}</div>
|
|
</div>
|
|
);
|
|
};
|
|
```
|