mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-15 01:35:17 +01:00
14 lines
273 B
JavaScript
14 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;
|
||
|
}
|