MCPcopy
hub / github.com/facebook/react / Frame

Function Frame

packages/react-devtools-shell/src/app/Iframe/index.js:23–63  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

21
22// $FlowFixMe[missing-local-annot]
23function Frame(props) {
24 const [element, setElement] = React.useState(null);
25
26 const ref = React.useRef();
27
28 React.useLayoutEffect(function () {
29 const iframe = ref.current;
30
31 if (iframe) {
32 const html = `
33 <!DOCTYPE html>
34 <html>
35 <body>
36 <div id="root"></div>
37 </body>
38 </html>
39 `;
40
41 const document = iframe.contentDocument;
42
43 document.open();
44 document.write(html);
45 document.close();
46
47 setElement(document.getElementById('root'));
48 }
49 }, []);
50
51 return (
52 <Fragment>
53 <iframe title="Test Iframe" ref={ref} style={iframeStyle} />
54 <iframe
55 title="Secured Iframe"
56 src="https://example.com"
57 style={iframeStyle}
58 />
59
60 {element ? createPortal(props.children, element) : null}
61 </Fragment>
62 );
63}
64
65function Greeting() {
66 return (

Callers

nothing calls this directly

Calls 3

createPortalFunction · 0.90
writeMethod · 0.65
closeMethod · 0.65

Tested by

no test coverage detected