From 81f278d5a1a9c67c59e5bcef178304491ef6acac Mon Sep 17 00:00:00 2001 From: Yury Shevchenko Date: Sun, 6 Mar 2022 17:13:50 -0800 Subject: [PATCH] Check that iframe ref is not null before changing its style --- src/components/link-preview/instagram.jsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/link-preview/instagram.jsx b/src/components/link-preview/instagram.jsx index 490db3d6a..6e8310041 100644 --- a/src/components/link-preview/instagram.jsx +++ b/src/components/link-preview/instagram.jsx @@ -29,8 +29,10 @@ export default function InstagramPreview({ url }) { useEffect(() => { startEventListening(); // set default frame height - const r = aspectRatio.get(url, 470 / 400); - iframeRef.current.style.height = `${iframeRef.current.offsetWidth * r}px`; + if (iframeRef.current) { + const r = aspectRatio.get(url, 470 / 400); + iframeRef.current.style.height = `${iframeRef.current.offsetWidth * r}px`; + } }, [url]); if (isPrivate) {