import React from 'react' ; import { Illustration } from '@bug-ui' ; interface ErrorBoundaryState { hasError : boolean ; } class ErrorBoundary extends React . Component < { } , ErrorBoundaryState > { constructor ( props ) { super ( props ) ; this . state = { hasError : false } ; } static getDerivedStateFromError ( error ) { return { hasError : true } ; } componentDidCatch ( error , errorInfo ) { console . log ( error , errorInfo ) ; } render ( ) { if ( this . state . hasError ) { return < Illustration type = "error" / > ; } return this . props . children ; } } export default ErrorBoundary ;