UNPKG

@leafygreen-ui/hooks

Version:
18 lines 1.12 kB
export interface UseEventOptions { options?: Omit<AddEventListenerOptions, 'once'>; dependencies?: Array<any>; enabled?: boolean | 'once'; element?: Document | HTMLElement; } /** * Hook to subscribe to an event listener. * @param type Represents the event type to listen for. * @param eventCallback Event listener callback function. * @param optional Optional third argument passed to function with implementation specifications * @param optional.options Parameter to specify options passed to the eventListener. * @param optional.enabled Determines whether or not the useEffect hook should run. * @param optional.dependencies Array to be passed to useEffect hook, such that the hook will only run if the array's values have changed. * @param optional.element Value to be passed as target of event handler, will default to document. */ export default function useEventListener<Type extends keyof DocumentEventMap>(type: Type, eventCallback: (e: DocumentEventMap[Type]) => void, { options, enabled, dependencies, element, }?: UseEventOptions): void; //# sourceMappingURL=useEventListener.d.ts.map