ai-chatbot/vendor/zoo-modeling-app/HicadManufacturingSlot.tsx.template

41 lines
944 B
Plaintext

import { Component, lazy, Suspense, type ErrorInfo, type ReactNode } from 'react'
const ManufacturingLauncher = lazy(() =>
import('./HicadManufacturingLauncher').then((module) => ({
default: module.HicadManufacturingLauncher,
}))
)
class ManufacturingSlotBoundary extends Component<
{ children: ReactNode },
{ failed: boolean }
> {
state = { failed: false }
static getDerivedStateFromError() {
return { failed: true }
}
componentDidCatch(error: unknown, info: ErrorInfo) {
console.error('[HiCAD Manufacturing] Launcher failed safely', error, info)
}
render() {
return this.state.failed ? null : this.props.children
}
}
export function HicadManufacturingSlot({
projectName,
}: {
projectName: string
}) {
return (
<ManufacturingSlotBoundary>
<Suspense fallback={null}>
<ManufacturingLauncher projectName={projectName} />
</Suspense>
</ManufacturingSlotBoundary>
)
}