Ram2005 commited on
Commit
fc8f11d
·
verified ·
1 Parent(s): 37496fa

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, errorInfo) {
14
- console.error('Bharat Tech Atlas Error:', error, errorInfo)
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="text-center space-y-4">
22
- <div className="text-6xl">🗺💥</div>
23
- <h1 className="text-xl font-bold text-atlas-text">Something went wrong</h1>
24
- <p className="text-sm text-atlas-muted max-w-md">
25
- The map encountered an unexpected error. This usually happens when WebGL is not supported or the browser is outdated.
26
  </p>
27
  <button
28
- onClick={() => window.location.reload()}
29
- className="px-4 py-2 bg-brand-500/20 text-brand-400 rounded-lg text-sm font-medium hover:bg-brand-500/30 transition-colors"
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>