Created
April 6, 2023 11:25
-
-
Save danilowoz/3a6c29779f7ebae45a9912106cdd85b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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