fix: guard access to a react ref before using it

This was causing some errors ever since we started using the ref
in an event handler - I'm not entirely sure why the ref stops
being valid, unless it's a lifecycle thing. But anyway, this
seems to stop the error in testing.
This commit is contained in:
Michael Terry
2022-03-03 09:48:41 -05:00
committed by Michael Terry
parent 48aad3951a
commit 7b945a9fce

View File

@@ -28,7 +28,9 @@ export default function LmsHtmlFragment({
const iframe = useRef(null);
function resetIframeHeight() {
iframe.current.height = iframe.current.contentWindow.document.body.scrollHeight;
if (iframe.current) {
iframe.current.height = iframe.current.contentWindow.document.body.scrollHeight;
}
}
useEffect(() => {