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:
committed by
Michael Terry
parent
48aad3951a
commit
7b945a9fce
@@ -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(() => {
|
||||
|
||||
Reference in New Issue
Block a user