MCPcopy Create free account
hub / github.com/Nutlope/llamacoder / ReactCodeRunner

Function ReactCodeRunner

components/code-runner-react.tsx:12–37  ·  view source on GitHub ↗
({
  files,
  onRequestFix,
}: {
  files: Array<{ path: string; content: string }>;
  onRequestFix?: (e: string) => void;
})

Source from the content-addressed store, hash-verified

10import { getSandpackConfig } from "@/lib/sandpack-config";
11
12export default function ReactCodeRunner({
13 files,
14 onRequestFix,
15}: {
16 files: Array<{ path: string; content: string }>;
17 onRequestFix?: (e: string) => void;
18}) {
19 const filesKey = files.map((f) => f.path + f.content).join("");
20 return (
21 <SandpackProvider
22 key={filesKey}
23 className="relative h-full w-full [&_.sp-preview-container]:flex [&_.sp-preview-container]:h-full [&_.sp-preview-container]:w-full [&_.sp-preview-container]:grow [&_.sp-preview-container]:flex-col [&_.sp-preview-container]:justify-center [&_.sp-preview-iframe]:grow"
24 {...getSandpackConfig(files)}
25 >
26 <SandpackPreview
27 showNavigator={false}
28 showOpenInCodeSandbox={false}
29 showRefreshButton={false}
30 showRestartButton={false}
31 showOpenNewtab={false}
32 className="h-full w-full"
33 />
34 {onRequestFix && <ErrorMessage onRequestFix={onRequestFix} />}
35 </SandpackProvider>
36 );
37}
38
39function ErrorMessage({ onRequestFix }: { onRequestFix: (e: string) => void }) {
40 const { sandpack } = useSandpack();

Callers

nothing calls this directly

Calls 1

getSandpackConfigFunction · 0.90

Tested by

no test coverage detected