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 <>

An error occured! code isn't exactly "enterprise" so feel free to tell me on Github or use pushshift directly

{this.state.error.message}

{this.state.errorInfo.componentStack.trim()}

; } else { return this.props.children; } } }