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..b5523238317a39 100644 --- a/docs/src/modules/components/DemoSandboxed.js +++ b/docs/src/modules/components/DemoSandboxed.js @@ -1,26 +1,14 @@ 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 { makeStyles, useTheme, jssPreset, StylesProvider } from '@material-ui/core/styles'; 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'; -const styles = (theme) => ({ - frame: { - backgroundColor: theme.palette.background.default, - flexGrow: 1, - height: 400, - border: 'none', - boxShadow: theme.shadows[1], - }, -}); - function FramedDemo(props) { - const { children } = props; - - const { document } = React.useContext(FrameContext); + const { children, document } = props; const theme = useTheme(); React.useEffect(() => { @@ -49,32 +37,62 @@ function FramedDemo(props) { } FramedDemo.propTypes = { children: PropTypes.node, + document: PropTypes.object.isRequired, }; +const useStyles = makeStyles( + (theme) => ({ + frame: { + backgroundColor: theme.palette.background.default, + flexGrow: 1, + height: 400, + border: 'none', + boxShadow: theme.shadows[1], + }, + }), + { name: 'DemoFrame' }, +); + function DemoFrame(props) { - const { children, classes, ...other } = props; + const { children, title, ...other } = props; + const classes = useStyles(); + /** + * @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} - + +