npm.io
1.1.3 • Published 4 years ago

@jdthornton/useonclickoutside

Licence
MIT
Version
1.1.3
Deps
1
Size
3 kB
Vulns
0
Weekly
0

@jdthornton/useonclickoutside

npm (scoped) npm bundle size (minified)

React on click outside ref target hook.

Install

$ npm install @jdthornton/useonclickoutside

Usage

import useOnClickOutside from "@jdthornton/useonclickoutside";

function App({ handleClickOutside }){
  const ref = useRef();

  useOnClickOutside(ref, handleClickOutside)

  return(
    <div ref={ref}>
      Don't click outside!
    </div>
  )
}