import { ErrorPage } from "pages/ErrorPage" import React, { ReactNode } from "react" interface ErrorBoundaryProps { children?: ReactNode } interface ErrorBoundaryState { error?: Error } export class ErrorBoundary extends React.Component { constructor(props: ErrorBoundaryProps) { super(props) this.state = {} } componentDidCatch(error: Error) { this.setState({ error }) } render() { if (this.state.error) return return this.props.children } }