commit
4047a7ec23
378 changed files with 29334 additions and 0 deletions
13
hooks/useDocumentClick.js
Normal file
13
hooks/useDocumentClick.js
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import { useEffect } from 'react';
|
||||
|
||||
export default function useDocumentClick(handler) {
|
||||
useEffect(() => {
|
||||
document.addEventListener('click', handler);
|
||||
|
||||
return () => {
|
||||
document.removeEventListener('click', handler);
|
||||
};
|
||||
}, [handler]);
|
||||
|
||||
return null;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue