import React from "react"; import ErrorPage from "../pages/ErrorPage"; interface Props { children: React.ReactNode; } interface State { hasError: boolean; error?: Error; } class ErrorBoundary extends React.Component { constructor(props: Props) { super(props); this.state = { hasError: false }; } static getDerivedStateFromError(error: Error): State { return { hasError: true, error, }; } render() { if (this.state.hasError) { return ( ); } return this.props.children; } } export default ErrorBoundary;