Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/netzo/deps/usehooks-ts.ts>useOnClickOutside

Full-stack Deno framework for building business web apps like internal tools, dashboards, admin panels and automated workflows.
Go to Latest
function useOnClickOutside
import { useOnClickOutside } from "https://deno.land/x/netzo@0.5.70/deps/usehooks-ts.ts";

Custom hook for handling clicks outside a specified element.

Examples

const containerRef = useRef(null); useOnClickOutside([containerRef], () => { // Handle clicks outside the container. });

Type Parameters

optional
T extends HTMLElement = HTMLElement
  • The type of the element's reference.

Parameters

ref: RefObject<T> | RefObject<T>[]
  • The React ref object(s) representing the element(s) to watch for outside clicks.
handler: (event: MouseEvent | TouchEvent) => void
  • The callback function to be executed when a click outside the element occurs.
optional
eventType: EventType
  • The mouse event type to listen for (optional, default is 'mousedown').