Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andarist/use-onclickoutside
React hook for listening for clicks outside of an element.
https://github.com/andarist/use-onclickoutside
hook hooks react reactjs
Last synced: 24 days ago
JSON representation
React hook for listening for clicks outside of an element.
- Host: GitHub
- URL: https://github.com/andarist/use-onclickoutside
- Owner: Andarist
- Created: 2018-10-28T21:55:17.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2023-12-12T09:10:21.000Z (11 months ago)
- Last Synced: 2024-05-15T13:14:50.243Z (6 months ago)
- Topics: hook, hooks, react, reactjs
- Language: TypeScript
- Homepage:
- Size: 19.5 KB
- Stars: 497
- Watchers: 3
- Forks: 27
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Security: SECURITY.md
Awesome Lists containing this project
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
{'Modal content'}
}
```