FaceSWAP / frontend /src /main.jsx
aditya-rAj19's picture
fix: add error boundary to surface React crashes, guard getRedirectResult
9c5b953
Raw
History Blame Contribute Delete
879 Bytes
import { StrictMode, Component } from 'react';
import { createRoot } from 'react-dom/client';
import './index.css';
import App from './App.jsx';
class ErrorBoundary extends Component {
constructor(props) { super(props); this.state = { error: null }; }
static getDerivedStateFromError(e) { return { error: e }; }
render() {
if (this.state.error) {
return (
<div style={{ padding: '2rem', color: '#D4DE95', fontFamily: 'sans-serif' }}>
<h2 style={{ color: '#ff6b6b' }}>App failed to load</h2>
<pre style={{ whiteSpace: 'pre-wrap', fontSize: '0.85rem', color: '#aaa' }}>
{this.state.error.message}
</pre>
</div>
);
}
return this.props.children;
}
}
createRoot(document.getElementById('root')).render(
<StrictMode>
<ErrorBoundary>
<App />
</ErrorBoundary>
</StrictMode>
);