import React, { ReactNode, Component } from 'react'; import './src/index.css'; import ReactDOM from 'react-dom/client'; import App from './App'; interface ErrorBoundaryProps { children?: ReactNode; } interface ErrorBoundaryState { hasError: boolean; error: any; } // Error Boundary to catch crashes and show a UI instead of white screen class ErrorBoundary extends Component { // FIX: Initialize state as a class property to resolve context issues. // state: ErrorBoundaryState = { // hasError: false, // error: null, // }; // FIX: Added a constructor to explicitly call super(props) and initialize state, resolving a potential context issue flagged by the type checker. constructor(props: ErrorBoundaryProps) { super(props); this.state = { hasError: false, error: null, }; } static getDerivedStateFromError(error: any): ErrorBoundaryState { return { hasError: true, error }; } componentDidCatch(error: any, errorInfo: any) { console.error("Uncaught error:", error, errorInfo); } render() { if (this.state.hasError) { return (

Algo deu errado :(

Ocorreu um erro ao carregar a aplicação.

            {this.state.error?.toString()}
          
); } return this.props.children; } } const rootElement = document.getElementById('root'); if (!rootElement) { throw new Error("Could not find root element to mount to"); } const root = ReactDOM.createRoot(rootElement); root.render( );