click-outside-detect
v1.0.2
Published
this package detect the click outside the components
Downloads
1
Maintainers
Readme
Getting Started with Click Outside Detect
Installing
Using npm:
npm i click-outside-detect
Using yarn:
yarn add click-outside-detect
Usege
Once the package is installed, you can import the library using import or require approach:
import OutsideClickDetect from "click-outside-detect";
this fuction require 2 peramters referance
and callback function
OutsideClickDetect(ref,callback());
Example
import { useRef } from "react";
import OutsideClickDetect from "click-outside-detect"; //import function
function App() {
const ref = useRef();
const callback = ()=>{
console.log("clicked outside here")
}
OutsideClickDetect(ref,callback)
return (
<div>
<div>
click here
</div>
<div ref={ref} >
Div
</div>
</div>
);
}
export default App;