dan
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
8 additions and
2 deletions
-
beta/src/components/MDX/Sandpack/SandpackRoot.tsx
|
|
@ -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 |
|
|
|