import React, { ErrorInfo, PropsWithChildren } from "react"; import { ErrorIcon, Typography } from "@firecms/ui"; export class ErrorBoundary extends React.Component>, { error: Error | null }> { constructor(props: any) { super(props); this.state = { error: null }; } // eslint-disable-next-line n/handle-callback-err static getDerivedStateFromError(error: Error) { return { error }; } componentDidCatch(error: Error, errorInfo: ErrorInfo) { console.error(error); // logErrorToMyService(error, errorInfo); } render() { if (this.state.error) { return (
Error
{this.state.error?.message ?? "See the error in the console"}
); } return this.props.children; } }