UNPKG

@ducor/hooks

Version:

A collection of useful React hooks for building modern web applications. Includes hooks for clipboard operations, window events, intervals, timeouts, and more.

15 lines (14 loc) 659 B
import type { RefObject } from "react"; export interface UseOutsideClickProps { ref?: RefObject<HTMLElement | null>; enabled?: boolean; handler?: (ev: Event) => void; } export declare function useCallbackRef<T extends (...args: any[]) => any>(callback: T | undefined, deps?: React.DependencyList): T; /** * `useOutsideClick` is a custom hook that detects click events outside of an element. * * @see Docs https://ui.ducor.net/hooks/use-outside-click */ declare const useOutsideClick: <T extends HTMLElement = HTMLDivElement>({ ref: elementRef, enabled, handler, }: UseOutsideClickProps) => RefObject<T | null>; export default useOutsideClick;