From 2cd4f1df2b0a4135afd1f8e9bd451d79cc29c8af Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 27 Jan 2026 22:58:08 +0000 Subject: [PATCH] debug: Add safe App version with lazy loading and error boundaries --- src/App.safe.tsx | 139 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 src/App.safe.tsx diff --git a/src/App.safe.tsx b/src/App.safe.tsx new file mode 100644 index 00000000..483d12d8 --- /dev/null +++ b/src/App.safe.tsx @@ -0,0 +1,139 @@ +import { useState, Suspense, lazy } from 'react'; +import './App.css'; + +// Lazy load components to identify which one is breaking +const StudentDashboard = lazy(() => import('./pages/StudentDashboard')); +const ScoreFollowing = lazy(() => import('./pages/ScoreFollowing')); + +type ViewType = 'dashboard' | 'practice' | 'learn' | 'score-following'; + +function LoadingFallback({ message }: { message: string }) { + return ( +
+
+
⏳
+
{message}
+
+
+ ); +} + +function ErrorBoundary({ children }: { children: React.ReactNode }) { + const [hasError, setHasError] = useState(false); + const [error, setError] = useState(null); + + if (hasError) { + return ( +
+

❌ Erro ao carregar componente

+
+          {error?.toString()}
+          {'\n\n'}
+          {error?.stack}
+        
+ +
+ ); + } + + try { + return <>{children}; + } catch (e) { + setHasError(true); + setError(e as Error); + return null; + } +} + +function App() { + const [currentView, setCurrentView] = useState('dashboard'); + + return ( +
+
+
+
+
+

🎹 Piano Tutor

+ Treinamento Inteligente com IA +
+ +
+
+
+ +
+ + }> + {currentView === 'dashboard' && } + {currentView === 'score-following' && } + + +
+ + +
+ ); +} + +export default App;