42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import { Component, StrictMode, type ReactNode } from 'react'
|
|
import { createRoot } from 'react-dom/client'
|
|
import './index.css'
|
|
import App from './App.tsx'
|
|
|
|
class RootErrorBoundary extends Component<{ children: ReactNode }, { hasError: boolean }> {
|
|
constructor(props: { children: ReactNode }) {
|
|
super(props);
|
|
this.state = { hasError: false };
|
|
}
|
|
|
|
static getDerivedStateFromError() {
|
|
return { hasError: true };
|
|
}
|
|
|
|
componentDidCatch(error: Error) {
|
|
console.error('[UI] Fatal render error:', error);
|
|
}
|
|
|
|
render() {
|
|
if (this.state.hasError) {
|
|
return (
|
|
<div style={{ height: '100vh', display: 'grid', placeItems: 'center', background: '#000', color: '#93c5fd', fontFamily: 'monospace' }}>
|
|
<div style={{ textAlign: 'center' }}>
|
|
<p style={{ margin: 0, fontSize: '12px', textTransform: 'uppercase', letterSpacing: '0.08em' }}>UI Recovery Mode</p>
|
|
<p style={{ margin: '8px 0 0', fontSize: '11px', color: '#9ca3af' }}>Open devtools console for the runtime stack trace.</p>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
return this.props.children;
|
|
}
|
|
}
|
|
|
|
createRoot(document.getElementById('root')!).render(
|
|
<StrictMode>
|
|
<RootErrorBoundary>
|
|
<App />
|
|
</RootErrorBoundary>
|
|
</StrictMode>,
|
|
)
|