umami.waylonwalker.com/hooks/useDocumentClick.js
WaylonWalker 4047a7ec23 Initial commit
Created from https://vercel.com/new
2021-12-08 18:25:42 +00:00

13 lines
273 B
JavaScript

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