({
files,
onRequestFix,
}: {
files: Array<{ path: string; content: string }>;
onRequestFix?: (e: string) => void;
})
| 10 | import { getSandpackConfig } from "@/lib/sandpack-config"; |
| 11 | |
| 12 | export 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 | |
| 39 | function ErrorMessage({ onRequestFix }: { onRequestFix: (e: string) => void }) { |
| 40 | const { sandpack } = useSandpack(); |
nothing calls this directly
no test coverage detected