Skip to content

Latest commit

 

History

History

react

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
logo image

npm version bundle size npm download npm type definitions Commitizen friendly Gitmoji semantic-release code style: prettier License: MIT

@miyauci/react-click-outside

🚚 Install

npm i -s @miyauci/react-click-outside
or
yarn add @miyauci/react-click-outside

💡 Usage

This provides React Custom Hooks.

import React, { useRef } from 'react'
import { useClickOutside } from '@miyauci/react-click-outside'

const App: FC = () => {
  const ref = useRef<HTMLElement>(null)
  const onClick = () => console.log('Outside clicked')

  useClickOutside(ref, onClick)

  return (
    <div>
      Outer
      <div ref={ref}>
        <div>Inter</div>
      </div>
    </div>
  )
}

💞 Related