import { Component, ReactNode } from 'react' type Props = { children: ReactNode fallback?: ReactNode onRetry?: () => void showRetry?: boolean } type State = { hasError: boolean } export class ErrorBoundary extends Component { state: State = { hasError: false } static getDerivedStateFromError() { return { hasError: true } } componentDidCatch() {} handleRetry = () => { this.setState({ hasError: false }) if (this.props.onRetry) { this.props.onRetry() } } render() { if (this.state.hasError) { if (this.props.fallback) { return this.props.fallback } return (

Something went wrong loading this section

An error occurred while loading this component. Please try reloading it.

{(this.props.showRetry !== false) && (
)}
) } return this.props.children } }