rooks
Version:
Collection of awesome react hooks
17 lines (16 loc) • 862 B
TypeScript
import type { RefElementOrNull } from "../utils/utils";
/**
* useEventListenerRef hook
*
* A react hook to an event listener to an element
* Returns a ref
*
* @param {string} eventName The event to track`
* @param {Function} callback The callback to be called on event
* @param {object} listenerOptions The options to be passed to the event listener
* @param {boolean} isLayoutEffect Should it use layout effect. Defaults to false
* @returns {Function} A callback ref that can be used as ref prop
* @see https://rooks.vercel.app/docs/hooks/useEventListenerRef
*/
declare function useEventListenerRef(eventName: string, callback: (...args: unknown[]) => void, listenerOptions?: AddEventListenerOptions | EventListenerOptions | boolean, isLayoutEffect?: boolean): (refElement: RefElementOrNull<HTMLElement>) => void;
export { useEventListenerRef };