Better handling of file uploads

This commit is contained in:
Dane Everitt 2020-08-22 22:35:53 -07:00
parent f561089cad
commit b4c64d3dc0
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
3 changed files with 32 additions and 34 deletions

View file

@ -8,13 +8,13 @@ export default (eventName: string, handler: (e: Event | CustomEvent | UIEvent |
}, [ handler ]);
useEffect(() => {
const isSupported = document && document.addEventListener;
const isSupported = window && window.addEventListener;
if (!isSupported) return;
const eventListener = (event: any) => savedHandler.current(event);
document.addEventListener(eventName, eventListener, options);
window.addEventListener(eventName, eventListener, options);
return () => {
document.removeEventListener(eventName, eventListener);
window.removeEventListener(eventName, eventListener);
};
}, [ eventName, document ]);
}, [ eventName, window ]);
};