mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-27 04:45:54 +01:00
16 lines
299 B
JavaScript
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;
|