[Beta] Use React versions from package.json (#5100)

This commit is contained in:
dan
2022-09-23 22:39:11 +01:00
committed by GitHub
parent 0826c798a6
commit bd0f7c02f0

View File

@@ -13,7 +13,6 @@ import type {SandpackSetup} from '@codesandbox/sandpack-react';
type SandpackProps = {
children: React.ReactNode;
autorun?: boolean;
setup?: SandpackSetup;
showDevTools?: boolean;
};
@@ -68,7 +67,7 @@ ul {
`.trim();
function SandpackRoot(props: SandpackProps) {
let {children, setup, autorun = true, showDevTools = false} = props;
let {children, autorun = true, showDevTools = false} = props;
const [devToolsLoaded, setDevToolsLoaded] = React.useState(false);
const codeSnippets = React.Children.toArray(children) as React.ReactElement[];
const files = createFileMap(codeSnippets);
@@ -78,6 +77,13 @@ function SandpackRoot(props: SandpackProps) {
hidden: true,
};
let setup;
if (files['/package.json']) {
setup = {
dependencies: JSON.parse(files['/package.json'].code).dependencies,
};
}
return (
<div className="sandpack sandpack--playground sandbox my-8">
<SandpackProvider