umami/hooks/useDocumentClick.js
2023-05-17 23:20:06 -07:00

16 lines
299 B
JavaScript

import { useEffect } from 'react';
export function useDocumentClick(handler) {
useEffect(() => {
document.addEventListener('click', handler);
return () => {
document.removeEventListener('click', handler);
};
}, [handler]);
return null;
}
export default useDocumentClick;