import { Component, PropsWithChildren } from 'react' type ErrorBoundaryState = { hasError: boolean } export class ErrorBoundary extends Component< PropsWithChildren, ErrorBoundaryState > { constructor(props: any) { super(props) this.state = { hasError: false } } static getDerivedStateFromError(error: Error) { console.error(error) return { hasError: true } } componentDidCatch(error: Error, errorInfo: any) { console.error(error, errorInfo) } render() { if (this.state.hasError) { return ( <>
An error occurred, please contact support at{' '}
support@a11ywatch.com
{this.props.children} ) } return this.props.children } }