mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-13 03:13:47 +00:00
67ddcd8c68
* feat/table add react-table * feat/table add protected table route * feat/table upgrade dependencies * feat/table support parsing of new properties Co-authored-by: DeepSource Bot <bot@deepsource.io>
35 lines
786 B
React
35 lines
786 B
React
/* eslint-disable react/destructuring-assignment */
|
|
import React from 'react';
|
|
import { LoggingContext } from '../../../app/context/LoggingContext';
|
|
|
|
class ErrorBoundary extends React.Component {
|
|
static contextType = LoggingContext;
|
|
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = { error: null, errorInfo: null };
|
|
}
|
|
|
|
static getDerivedStateFromError(error) {
|
|
// Update state so next render shows fallback UI.
|
|
return { errorMessage: error.toString() };
|
|
}
|
|
|
|
componentDidCatch(error, info) {
|
|
this.setState({
|
|
error: error,
|
|
errorInfo: info,
|
|
});
|
|
this.context.emitError(error.toString());
|
|
}
|
|
|
|
render() {
|
|
if (this.state.errorMessage) {
|
|
return <p>:/</p>;
|
|
}
|
|
return this.props.children;
|
|
}
|
|
}
|
|
|
|
export default ErrorBoundary;
|