hedinne / use-onclickoutside

React hook for listening for clicks outside of an element.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

use-onclickoutside

React hook for listening for clicks outside of an element.

Usage

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>
}

About

React hook for listening for clicks outside of an element.


Languages

Language:JavaScript 57.0%Language:TypeScript 43.0%