@hooooks/use-event-listener
Version:
A custom React Hook that provides a declarative useEventListener with native event binding.
12 lines (11 loc) • 774 B
TypeScript
import { ReactInstance, Ref } from 'react';
declare type Options = {
capture?: boolean;
once?: boolean;
passive?: boolean;
};
export default function useEventListener(element: Window | Document | HTMLElement | Ref<HTMLElement | ReactInstance>, eventName: string, handler: (event: Event) => void, options?: boolean | Options): void;
export declare function addEventListener(element: any, eventName: string, handler: (event: Event) => void, options?: boolean | Options): () => void;
export declare function removeEventListener(element: any, eventName: string, handler: (event: Event) => void, options?: boolean | Options): void;
export declare function getTargetElement(element: Window | Document | HTMLElement | Ref<HTMLElement | ReactInstance>): any;
export {};