import React, { Component } from 'react'; interface ErrorBoundaryProps { children: React.ReactNode; } interface ErrorBoundaryState { hasError: boolean; error: Error; errorInfo: React.ErrorInfo; } export default class ErrorBoundary extends Component { constructor(props: ErrorBoundaryProps) { super(props); this.state = { hasError: false, error: { name: '', message: '' }, errorInfo: { componentStack: '' }, }; } componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void { console.error(error, errorInfo); this.setState({ hasError: true, error, errorInfo }); setTimeout(() => { window.location.reload(); }, 10000); } render() { if (this.state.hasError) { return (

Something went wrong. Restarting app in 10 seconds...

Error: {this.state.error.name}

Error message: {this.state.error.message}

Error cause: {this.state.error.cause}

Error component stack: {this.state.errorInfo.componentStack}

); } return this.props.children; } }