UNPKG

679 BTypeScriptView Raw
1declare type EventHandler<T, K extends keyof DocumentEventMap> = (this: T, ev: DocumentEventMap[K]) => any;
2/**
3 * Attaches an event handler outside directly to specified DOM element
4 * bypassing the react synthetic event system.
5 *
6 * @param element The target to listen for events on
7 * @param event The DOM event name
8 * @param handler An event handler
9 * @param capture Whether or not to listen during the capture event phase
10 */
11export default function useEventListener<T extends Element | Document | Window, K extends keyof DocumentEventMap>(eventTarget: T | (() => T), event: K, listener: EventHandler<T, K>, capture?: boolean | AddEventListenerOptions): void;
12export {};