1.0.2 • Published 1 year ago

click-outside-detect v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

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;