import React from "react"; export class ErrorBoundary extends React.Component { constructor(props: any) { super(props); this.state = { error: null, errorInfo: null }; } public componentDidCatch(error: any, errorInfo: any) { this.setState({ error, errorInfo, }); } public render() { if (this.state.errorInfo) { // Error path return (

Something went wrong.

{this.state.error && this.state.error.toString()}
{this.state.errorInfo.componentStack}
); } // Normally, just render children return this.props.children; } }