@miyauci/react-click-outside
v1.0.4
Published
react custom hooks for outside click
Downloads
27
Maintainers
Readme
@miyauci/react-click-outside
:truck: Install
npm i -s @miyauci/react-click-outside
or
yarn add @miyauci/react-click-outside
:bulb: 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>
)
}