You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
510 B
TypeScript

import * as React from 'react';
import PrettyError from '../widgets/PrettyError';
class ErrorBoundary extends React.Component {
state: {
error?: Error;
};
constructor(props: any) {
super(props);
this.state = { };
}
componentDidCatch(error: Error, info: any) {
this.setState({ error });
}
render() {
if (this.state.error) {
return (
<PrettyError error={this.state.error} />
);
}
return this.props.children;
}
}
export default ErrorBoundary;