fix(useSize): prevents accessing iframe's property when it's not defined

ref #442
This commit is contained in:
Manoj Bahuguna 2019-07-04 18:04:51 +00:00
parent cf68e36ad5
commit c9b5cdca42

View File

@ -45,7 +45,13 @@ const useSize = (
};
useEffect(() => {
const iframe: HTMLIFrameElement = ref.current!;
const iframe: HTMLIFrameElement = ref.current;
if(!iframe) {
// iframe will be undefined if component is already unmounted
return;
}
if (iframe.contentWindow) {
window = iframe.contentWindow!;
onWindow(window);