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: about 2 months 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 (about 1 year ago)
- Last Synced: 2024-11-01T13:38:35.321Z (about 2 months ago)
- Topics: hook, hooks, react, reactjs
- Language: TypeScript
- Homepage:
- Size: 19.5 KB
- Stars: 498
- Watchers: 3
- Forks: 27
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Security: SECURITY.md
Awesome Lists containing this project
- awesome - use-onclickoutside
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'}
}
```