import useEventListener from "@hooks/useEventListener"; import React from "react"; export default function useClickOutside( ref: React.RefObject, cb: (e: MouseEvent) => void, triggerRef: React.RefObject ) { useEventListener( "click", (e) => { console.log(e.target); if ( ref.current == null || ref.current.contains(e.target as Node) || triggerRef.current?.contains(e.target as Node) ) return; cb(e as unknown as MouseEvent); }, document ); }