website/src/components/IFrame.js (9 lines of code) (raw):

/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @format */ import React, {useState, useEffect} from 'react'; import {createPortal} from 'react-dom'; // https://stackoverflow.com/a/34744946 export const IFrame = ({children, ...props}) => { const [contentRef, setContentRef] = useState(null); const mountNode = contentRef?.contentWindow?.document?.body; return ( <iframe {...props} ref={setContentRef}> {mountNode && createPortal(children, mountNode)} </iframe> ); };