# handle-click-outside

> React Hook Handle Click Outside

Latest version **0.0.7** (published 2020-12-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install handle-click-outside
pnpm add handle-click-outside
yarn add handle-click-outside
bun add handle-click-outside
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2020-12-28 |
| First published | 2020-12-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 7.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | dat_omega_sherly |

## Links

- npm: https://www.npmjs.com/package/handle-click-outside
- Repository: https://github.com/magicd-ops/handle-click-outside
- Homepage: https://github.com/magicd-ops/handle-click-outside#readme
- Issues: https://github.com/magicd-ops/handle-click-outside/issues
- npm.io page: https://npm.io/package/handle-click-outside

## Dependencies (2)

- [babel-loader](https://npm.io/package/babel-loader.md) ^8.2.2
- [@material-ui/core](https://npm.io/package/@material-ui/core.md) ^4.11.2

## Recent versions

- 0.0.7 (latest) — 2020-12-28
- 0.0.6 — 2020-12-28
- 0.0.5 — 2020-12-28
- 0.0.4 — 2020-12-28
- 0.0.3 — 2020-12-28
- 0.0.2 — 2020-12-28
- 0.0.1 — 2020-12-28

## README

# handle-click-outside
React Hook Handle Click Outside

This module is only used in React Hooks and need useState, useRef, useEffect of current function

> To use this module :
```
import React, { useState, useRef, useEffect } from 'react';
import initRef from 'handle-click-outside';

let [ Ref, Orig, setHandler ] = initRef({useState, useRef, useEffect, document, index: 0});

```

Ref: the reference box to toggle

Orig: the original box for click to show/hide Ref

setHandler: to set show/hide in Ref manually

```
<Orig className={className} ....>some text</Orig>
<Ref className={className} .... defaultDisplay="block">
  <div onClick={() => setHandler(false)}>some text</div>
</Ref>
```

defaultDisplay: this method will set display ( default is flex ) when Ref is in show mode

> It can be used in multi Ref Orig box in a certain function and just set index in every Ref Orig

```
let [ Ref, Orig, setHandler ] = initRef({useState, useRef, useEffect, document, index: 0});
let [ Ref2, Orig2, setHandler2 ] = initRef({useState, useRef, useEffect, document, index: 1});


<Orig className={className} ....>some text</Orig>
<Ref className={className} .... defaultDisplay="block">
  <div onClick={() => setHandler(false)}>some text</div>
</Ref>

<Orig2 className={className} ....>some text</Orig>
<Ref2 className={className} .... defaultDisplay="block">
  <div onClick={() => setHandler2(false)}>some text</div>
</Ref>
```

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