import * as React from "react" ; interface ErrorBoundary { error : Error | null ; } class ErrorBoundary2 extends React . Component < Partial < ErrorBoundary > > { state : ErrorBoundary ; constructor ( props ) { super ( props ) ; this . state = { error : null , } ; } static getDerivedStateFromError ( error ) { return { error } ; } render ( ) { if ( ! ! this . state . error ) { return < h1 > 에러가 발생했습니다 . 에러 내용 : { this . state . error . toString ( ) } < /h1>; } else { return this . props . children ; } } } export default ErrorBoundary2 ;