Spaces:
Running
Running
Update main.js
Browse files
main.js
CHANGED
|
@@ -3,11 +3,11 @@ import ReactDOM from 'react-dom/client'
|
|
| 3 |
import App from './cointube'
|
| 4 |
import './index.css'
|
| 5 |
|
| 6 |
-
//
|
| 7 |
class ErrorBoundary extends React.Component {
|
| 8 |
constructor(props) {
|
| 9 |
super(props);
|
| 10 |
-
this.state = { hasError: false, error: null };
|
| 11 |
}
|
| 12 |
|
| 13 |
static getDerivedStateFromError(error) {
|
|
@@ -15,16 +15,23 @@ class ErrorBoundary extends React.Component {
|
|
| 15 |
}
|
| 16 |
|
| 17 |
componentDidCatch(error, errorInfo) {
|
| 18 |
-
console.error("Error atrapado:", error, errorInfo);
|
|
|
|
| 19 |
}
|
| 20 |
|
| 21 |
render() {
|
| 22 |
if (this.state.hasError) {
|
| 23 |
return (
|
| 24 |
-
<div
|
| 25 |
-
<
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
</div>
|
| 29 |
);
|
| 30 |
}
|
|
|
|
| 3 |
import App from './cointube'
|
| 4 |
import './index.css'
|
| 5 |
|
| 6 |
+
// Componente para atrapar errores y evitar la pantalla blanca de la muerte
|
| 7 |
class ErrorBoundary extends React.Component {
|
| 8 |
constructor(props) {
|
| 9 |
super(props);
|
| 10 |
+
this.state = { hasError: false, error: null, errorInfo: null };
|
| 11 |
}
|
| 12 |
|
| 13 |
static getDerivedStateFromError(error) {
|
|
|
|
| 15 |
}
|
| 16 |
|
| 17 |
componentDidCatch(error, errorInfo) {
|
| 18 |
+
console.error("Error atrapado en la App:", error, errorInfo);
|
| 19 |
+
this.setState({ errorInfo });
|
| 20 |
}
|
| 21 |
|
| 22 |
render() {
|
| 23 |
if (this.state.hasError) {
|
| 24 |
return (
|
| 25 |
+
<div className="min-h-screen bg-gray-900 text-white flex flex-col items-center justify-center p-4">
|
| 26 |
+
<div className="bg-red-900/50 p-6 rounded-lg border border-red-500 max-w-2xl w-full">
|
| 27 |
+
<h1 className="text-2xl font-bold mb-4 text-red-300">⚠️ Algo salió mal</h1>
|
| 28 |
+
<p className="mb-4">La aplicación ha encontrado un error crítico.</p>
|
| 29 |
+
<div className="bg-black p-4 rounded overflow-auto text-sm font-mono">
|
| 30 |
+
<p className="text-red-400 font-bold">{this.state.error && this.state.error.toString()}</p>
|
| 31 |
+
<br/>
|
| 32 |
+
<p className="text-gray-500">{this.state.errorInfo && this.state.errorInfo.componentStack}</p>
|
| 33 |
+
</div>
|
| 34 |
+
</div>
|
| 35 |
</div>
|
| 36 |
);
|
| 37 |
}
|