From 6bcdc0f8bad5feda074fa60b1ccdcb1d21c9f52d Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Tue, 21 Apr 2020 17:25:14 +0200 Subject: [PATCH 1/3] [docs] Replace react-frame-component with concurrent safe impl --- docs/package.json | 1 - docs/src/modules/components/DemoSandboxed.js | 37 +++++++++++++++----- yarn.lock | 5 --- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/docs/package.json b/docs/package.json index 929be5e8d5f502..2ed97698a5afbe 100644 --- a/docs/package.json +++ b/docs/package.json @@ -95,7 +95,6 @@ "react-dom": "^16.13.0", "react-draggable": "^4.0.3", "react-final-form": "^6.3.0", - "react-frame-component": "^4.1.1", "react-is": "^16.13.0", "react-number-format": "^4.0.8", "react-redux": "^7.1.1", diff --git a/docs/src/modules/components/DemoSandboxed.js b/docs/src/modules/components/DemoSandboxed.js index 706e02ac8bc604..38e0264cc04bac 100644 --- a/docs/src/modules/components/DemoSandboxed.js +++ b/docs/src/modules/components/DemoSandboxed.js @@ -1,9 +1,10 @@ import React from 'react'; +import ReactDOM from 'react-dom'; import PropTypes from 'prop-types'; import { create } from 'jss'; import { withStyles, useTheme, jssPreset, StylesProvider } from '@material-ui/core/styles'; +import { exactProp } from '@material-ui/utils'; import rtl from 'jss-rtl'; -import Frame, { FrameContext } from 'react-frame-component'; import { useSelector } from 'react-redux'; import DemoErrorBoundary from 'docs/src/modules/components/DemoErrorBoundary'; @@ -18,9 +19,7 @@ const styles = (theme) => ({ }); function FramedDemo(props) { - const { children } = props; - - const { document } = React.useContext(FrameContext); + const { children, document } = props; const theme = useTheme(); React.useEffect(() => { @@ -49,22 +48,44 @@ function FramedDemo(props) { } FramedDemo.propTypes = { children: PropTypes.node, + document: PropTypes.object.isRequired, }; function DemoFrame(props) { - const { children, classes, ...other } = props; + const { children, classes, title } = props; + /** + * @type {import('react').Ref} + */ + const frameRef = React.useRef(null); + + const [mounted, setMounted] = React.useState(false); + React.useEffect(() => { + setMounted(true); + }, []); + + const document = frameRef.current?.contentDocument; return ( - - {children} - + +