@ajeamme/use-click-outside
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

How to use

const Component = () => {
  const rootRef = useRef<HTMLDivElement>()
  const [isOpen, setIsOpen] = React.useState(false)

  useClickOutside(isOpen, setIsOpen, rootRef)

  return (
    <div ref={rootRef}>
      <button>{isOpen ? 'Open dropdown' : 'Close dropdown'}</button>

      {isOpen && <MyDropdown />}
    </div>
  )
}

Readme

Keywords

none

Package Sidebar

Install

npm i @ajeamme/use-click-outside

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

8.53 kB

Total Files

10

Last publish

Collaborators

  • jinga