UNPKG

@react-hookz/web

Version:

React hooks done right, for browser and SSR.

11 lines (10 loc) 588 B
import { type MutableRefObject, type RefObject } from 'react'; /** * Triggers a callback when the user clicks outside a target element. * * @param ref React ref object containing the target HTML element. * @param callback Callback invoked when the user clicks outside the target element. * @param events List of events that will be used as triggers for the outside click. Default: * 'mousedown', 'touchstart' */ export declare function useClickOutside<T extends HTMLElement>(ref: RefObject<T | null> | MutableRefObject<T | null>, callback: EventListener, events?: string[]): void;