# @jsnooks/use-hover

> React Hook to detect a hover on an any React Element

Latest version **1.0.1** (published 2023-10-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install @jsnooks/use-hover
pnpm add @jsnooks/use-hover
yarn add @jsnooks/use-hover
bun add @jsnooks/use-hover
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2023-10-05 |
| First published | 2023-10-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 1.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Song Jae Seok |
| Maintainers | largopie |
| Keywords | react, hooks, hover, usehover |

## Links

- npm: https://www.npmjs.com/package/@jsnooks/use-hover
- Repository: https://github.com/Largopie/jsnooks
- Homepage: https://github.com/Largopie/jsnooks#readme
- Issues: https://github.com/Largopie/jsnooks/issues
- npm.io page: https://npm.io/package/@jsnooks/use-hover

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2023-10-05
- 1.0.0 — 2023-10-05

## README

# useHover

[실습예제]

```js
import React, { useRef, useEffect } from 'react';

export const useHover = (onHover) => {
  if (typeof onHover !== 'function') {
    return;
  }
  const element = useRef();
  useEffect(() => {
    if (element.current) {
      element.current.addEventListener('mouseenter', onHover);
    }
    return () => {
      if (element.current) {
        element.current.removeEventListener('mouseenter', onHover);
      }
    };
  }, []);
  return element;
};

const App = () => {
  const sayHello = () => console.log('say hello');
  const title = useHover(sayHello);

  return (
    <div className='App'>
      <h1 ref={title}>Hi</h1>
    </div>
  );
};

export default App;
```

---
_Source: https://npm.io/package/@jsnooks/use-hover · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
