import * as React from "react"; import { ErrorInfo } from "react"; import { CLASSES } from "../Types"; /** @hidden @internal */ export interface IErrorBoundaryProps { message: string; } /** @hidden @internal */ export interface IErrorBoundaryState { hasError: boolean; } /** @hidden @internal */ export class ErrorBoundary extends React.Component { constructor(props: IErrorBoundaryProps) { super(props); this.state = { hasError: false }; } static getDerivedStateFromError(error: Error) { return { hasError: true }; } componentDidCatch(error: Error, errorInfo: ErrorInfo) { console.debug(error); console.debug(errorInfo); } render() { if (this.state.hasError) { return (
{this.props.message}
); } return this.props.children; } }