Spaces:
Sleeping
Sleeping
fix: add React ErrorBoundary to prevent white-screen crashes
Browse files
frontend/src/components/ErrorBoundary.jsx
CHANGED
|
@@ -10,23 +10,23 @@ export default class ErrorBoundary extends React.Component {
|
|
| 10 |
return { hasError: true, error }
|
| 11 |
}
|
| 12 |
|
| 13 |
-
componentDidCatch(error,
|
| 14 |
-
console.error('
|
| 15 |
}
|
| 16 |
|
| 17 |
render() {
|
| 18 |
if (this.state.hasError) {
|
| 19 |
return (
|
| 20 |
<div className="min-h-screen bg-atlas-bg flex items-center justify-center p-4">
|
| 21 |
-
<div className="
|
| 22 |
-
<div className="text-
|
| 23 |
-
<
|
| 24 |
-
<p className="text-sm text-atlas-muted
|
| 25 |
-
The map encountered an
|
| 26 |
</p>
|
| 27 |
<button
|
| 28 |
-
onClick={() => window.location.reload()}
|
| 29 |
-
className="
|
| 30 |
>
|
| 31 |
Reload Page
|
| 32 |
</button>
|
|
|
|
| 10 |
return { hasError: true, error }
|
| 11 |
}
|
| 12 |
|
| 13 |
+
componentDidCatch(error, info) {
|
| 14 |
+
console.error('ErrorBoundary caught:', error, info)
|
| 15 |
}
|
| 16 |
|
| 17 |
render() {
|
| 18 |
if (this.state.hasError) {
|
| 19 |
return (
|
| 20 |
<div className="min-h-screen bg-atlas-bg flex items-center justify-center p-4">
|
| 21 |
+
<div className="glass rounded-2xl p-8 max-w-md text-center">
|
| 22 |
+
<div className="text-4xl mb-4">⚠️</div>
|
| 23 |
+
<h2 className="text-xl font-bold text-atlas-text mb-2">Something went wrong</h2>
|
| 24 |
+
<p className="text-sm text-atlas-muted mb-4">
|
| 25 |
+
The map encountered an error. Reloading usually fixes transient rendering/network issues.
|
| 26 |
</p>
|
| 27 |
<button
|
| 28 |
+
onClick={() => { this.setState({ hasError: false, error: null }); window.location.reload(); }}
|
| 29 |
+
className="bg-brand-500 hover:bg-brand-600 text-white px-4 py-2 rounded-lg text-sm font-medium transition-colors"
|
| 30 |
>
|
| 31 |
Reload Page
|
| 32 |
</button>
|