import * as React from 'react'; export interface ErrorState { errorOccurred: boolean, errorInfo: object, error: object, } export class ErrorWrapper extends React.Component<{}, ErrorState> { constructor(props) { super(props) this.state = { errorOccurred: false, errorInfo: null, error: null } } componentDidCatch(error, info) { this.setState({ errorOccurred: true, errorInfo: info, error: error }) } render() { if (this.state.errorOccurred) { console.log(this.state.error); console.log(this.state.errorInfo); return <>
>; } else { return this.props.children; } } }