React Hook useEvent

Date: 2023-05-23
/* eslint-disable react-hooks/exhaustive-deps */
import { useEffect } from "react";

export function useEvent(element: Node, eventName: string, listener: (e: any) => any, deps: any[] = []) {
    useEffect(() => {
        element.addEventListener(eventName, listener);
        return () => element.removeEventListener(eventName, listener);
    }, deps);
};
78200cookie-checkReact Hook useEvent