# use-onclickoutside

> React hook for listening for clicks outside of an element.

Latest version **0.4.1** (published 2022-06-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install use-onclickoutside
pnpm add use-onclickoutside
yarn add use-onclickoutside
bun add use-onclickoutside
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.1 |
| Published | 2022-06-14 |
| First published | 2018-10-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 10.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 496 |
| Maintainers | andarist |

## Links

- npm: https://www.npmjs.com/package/use-onclickoutside
- Repository: https://github.com/Andarist/use-onclickoutside
- Homepage: https://github.com/Andarist/use-onclickoutside#readme
- Issues: https://github.com/Andarist/use-onclickoutside/issues
- npm.io page: https://npm.io/package/use-onclickoutside

## Dependencies (2)

- [use-latest](https://npm.io/package/use-latest.md) ^1.2.1
- [are-passive-events-supported](https://npm.io/package/are-passive-events-supported.md) ^1.1.1

## Recent versions

- 0.4.1 (latest) — 2022-06-14
- 0.4.0 — 2021-06-22
- 0.3.2 — 2021-03-20
- 0.3.1 — 2019-03-25
- 0.3.0 — 2019-02-04
- 0.2.2 — 2018-11-10
- 0.2.1 — 2018-11-04
- 0.2.0 — 2018-11-01
- 0.1.1 — 2018-11-01
- 0.1.0 — 2018-10-29

## README

# use-onclickoutside

React hook for listening for clicks outside of an element.

## Usage

```js
import * as React from 'react'
import useOnClickOutside from 'use-onclickoutside'

export default function Modal({ close }) {
  const ref = React.useRef(null)
  useOnClickOutside(ref, close)

  return <div ref={ref}>{'Modal content'}</div>
}
```

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