UNPKG

@thibault.sh/hooks

Version:

A comprehensive collection of React hooks for browser storage, UI interactions, and more

14 lines (11 loc) 617 B
import { RefObject } from 'react'; type EventMap = WindowEventMap & HTMLElementEventMap & DocumentEventMap; /** * Hook that adds an event listener to a target element or window * @param eventName - Name of the event to listen for * @param handler - Event handler function * @param element - Target element (defaults to window) * @param options - AddEventListener options */ declare function useEventListener<K extends keyof EventMap>(eventName: K, handler: (event: EventMap[K]) => void, element?: RefObject<HTMLElement> | null, options?: boolean | AddEventListenerOptions): void; export { useEventListener };