diff --git a/src/components/PreviewContent.tsx b/src/components/PreviewContent.tsx index 15a8b52..5e07a59 100644 --- a/src/components/PreviewContent.tsx +++ b/src/components/PreviewContent.tsx @@ -20,6 +20,7 @@ import { MagicWandIcon } from "@radix-ui/react-icons" import { ErrorBoundary } from "react-error-boundary" import { ErrorTabContent } from "./ErrorTabContent" import { cn } from "@/lib/utils" +import { useCallback } from "react" export interface PreviewContentProps { code: string @@ -50,9 +51,17 @@ export const PreviewContent = ({ errorMessage, circuitJson, }: PreviewContentProps) => { + const [activeTab, setActiveTab] = useState("pcb") + + useEffect(() => { + if (errorMessage) { + setActiveTab("error") + } + }, [errorMessage]) + return (
- +
diff --git a/src/hooks/use-run-tsx/index.tsx b/src/hooks/use-run-tsx/index.tsx index 0287238..1b18e16 100644 --- a/src/hooks/use-run-tsx/index.tsx +++ b/src/hooks/use-run-tsx/index.tsx @@ -83,7 +83,9 @@ export const useRunTsx = ({ const __tscircuit_require = (name: string) => { if (!preSuppliedImports[name]) { - throw new Error(`Import "${name}" not found`) + throw new Error( + `Import "${name}" not found (imports available: ${Object.keys(preSuppliedImports).join(",")})`, + ) } return preSuppliedImports[name] }