use-on-outside-click
Version:
A lightweight and flexible React hook to detect clicks outside one or multiple elements.
10 lines (9 loc) • 369 B
TypeScript
import { RefObject } from 'react';
type TargetElement = HTMLElement | null;
type ElementInput = RefObject<TargetElement> | TargetElement | string | null;
type ElementList = ElementInput | ElementInput[];
type Options = {
skip?: boolean;
};
export default function useOnOutsideClick(elements: ElementList, callback: () => void, { skip }?: Options): void;
export {};