import React, { Component } from "react"; export class ErrorBoundary extends Component, { error: any }> { constructor(props: React.PropsWithChildren<{}>) { super(props); this.state = { error: null }; } static getDerivedStateFromError(error: any) { // Update state so the next render will show the fallback UI. return { error }; } componentDidCatch(error: Error, errorInfo: React.ErrorInfo) { //console.error(error, errorInfo); } render() { if (this.state.error) { return (

Something went wrong.

{"" + this.state.error}

); } return this.props.children; } }