mirror of
https://github.com/streamich/react-use.git
synced 2026-01-18 14:06:52 +00:00
fix(useSize): prevents accessing iframe's property when it's not defined
ref #442
This commit is contained in:
parent
cf68e36ad5
commit
c9b5cdca42
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user