Skip to content

Instantly share code, notes, and snippets.

@danilowoz
Created April 6, 2023 11:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danilowoz/3a6c29779f7ebae45a9912106cdd85b8 to your computer and use it in GitHub Desktop.
Save danilowoz/3a6c29779f7ebae45a9912106cdd85b8 to your computer and use it in GitHub Desktop.
mport { Sandpack } from "@codesandbox/sandpack-react";
const App = () => {
const files = {}
return (
<SandpackProvider
files={files}
theme="light"
template="static"
>
<SandpackReactContext>
{({ files, updateFile }) => {
const fileListValues = Object.values(files);
const fileListKeys = Object.keys(files);
return (
<SandpackLayout>
<SandpackStack style={{ padding: "10px 0" }}>
<CodeEditor
code={fileListValues[0].code}
filePath={fileListKeys[0]}
onCodeUpdate={(newCode) =>
updateFile(fileListKeys[0], newCode)
}
showTabs
/>
</SandpackStack>
<SandpackStack style={{ padding: "10px 0" }}>
<CodeEditor
code={fileListValues[1].code}
filePath={fileListKeys[1]}
onCodeUpdate={(newCode) =>
updateFile(fileListKeys[1], newCode)
}
showTabs
/>
</SandpackStack>
<SandpackPreview />
</SandpackLayout>
);
}}
</SandpackReactContext>
</SandpackProvider>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment