@tremendous/help
    Preparing search index...

    Function useOnClickOutside

    • Custom hook to detect clicks outside of a specified element.

      This hook sets up an event listener that triggers the provided handler when a click is detected outside the specified element.

      Type Parameters

      • T extends HTMLElement = HTMLElement

        The type of the target element.

      Parameters

      • ref: RefObject<T>

        A ref object pointing to the target element.

      • handler: Handler

        The function to call when a click outside the element is detected.

      • OptionalmouseEvent: "mousedown" | "mouseup" = "mousedown"

        The type of mouse event to listen for.

      Returns void

      const ref = useRef<HTMLDivElement>(null);
      useOnClickOutside(ref, () => {
      console.log('Clicked outside the element');
      });