diff --git a/docs/src/modules/components/DemoSandboxed.js b/docs/src/modules/components/DemoSandboxed.js
index 9814f3ad84f828..8d1b9bc0cfad37 100644
--- a/docs/src/modules/components/DemoSandboxed.js
+++ b/docs/src/modules/components/DemoSandboxed.js
@@ -2,6 +2,8 @@ import * as React from 'react';
import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
import { create } from 'jss';
+import createCache from '@emotion/cache';
+import { CacheProvider } from '@emotion/react';
import { makeStyles, useTheme, jssPreset, StylesProvider } from '@material-ui/core/styles';
import rtl from 'jss-rtl';
import DemoErrorBoundary from 'docs/src/modules/components/DemoErrorBoundary';
@@ -25,13 +27,25 @@ function FramedDemo(props) {
};
}, [document]);
+ const cache = React.useMemo(
+ () =>
+ createCache({
+ key: 'iframe-demo',
+ prepend: true,
+ container: document.head,
+ }),
+ [document],
+ );
+
const getWindow = React.useCallback(() => document.defaultView, [document]);
return (
- {React.cloneElement(children, {
- window: getWindow,
- })}
+
+ {React.cloneElement(children, {
+ window: getWindow,
+ })}
+
);
}
@@ -54,7 +68,8 @@ const useStyles = makeStyles(
);
function DemoFrame(props) {
- const { children, title, ...other } = props;
+ const { children, name, ...other } = props;
+ const title = `${name} demo`;
const classes = useStyles();
/**
* @type {import('react').Ref}
@@ -95,7 +110,7 @@ function DemoFrame(props) {
DemoFrame.propTypes = {
children: PropTypes.node.isRequired,
- title: PropTypes.string.isRequired,
+ name: PropTypes.string.isRequired,
};
/**
@@ -105,7 +120,7 @@ DemoFrame.propTypes = {
function DemoSandboxed(props) {
const { component: Component, iframe, name, onResetDemoClick, ...other } = props;
const Sandbox = iframe ? DemoFrame : React.Fragment;
- const sandboxProps = iframe ? { title: `${name} demo`, ...other } : {};
+ const sandboxProps = iframe ? { name, ...other } : {};
const t = useTranslate();