import React from "react"; interface ErrorBoundaryState { hasError: boolean; } class ErrorBoundary extends React.Component, ErrorBoundaryState> { constructor(props: {}) { super(props); this.state = { hasError: false }; } static getDerivedStateFromError(error: any) { // Update state so the next render shows the fallback UI return { hasError: true }; } componentDidCatch(error: any, info: any) { // You can also log the error to an error reporting service console.log(error, info); } render() { if (this.state.hasError) { // You can render any custom fallback UI return

Something went wrong.

; } return this.props.children; } } export default ErrorBoundary;