Clean up: Remove component files
This commit is contained in:
parent
17752d5667
commit
a22416031d
@ -1,44 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
|
|
||||||
interface ErrorBoundaryState {
|
|
||||||
hasError: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Last line of defence: a render crash shows a recovery screen instead of a
|
|
||||||
* blank page, so a user never loses sight of their work without an explanation.
|
|
||||||
*/
|
|
||||||
class ErrorBoundary extends React.Component<{ children: React.ReactNode }, ErrorBoundaryState> {
|
|
||||||
state: ErrorBoundaryState = { hasError: false };
|
|
||||||
|
|
||||||
static getDerivedStateFromError(): ErrorBoundaryState {
|
|
||||||
return { hasError: true };
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidCatch(error: Error, info: React.ErrorInfo): void {
|
|
||||||
// Kept in the console for now; a real logging endpoint is a Backend concern.
|
|
||||||
console.error('TaskFlow crashed while rendering', error, info.componentStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
render(): React.ReactNode {
|
|
||||||
if (this.state.hasError) {
|
|
||||||
return (
|
|
||||||
<div className="app-error" role="alert">
|
|
||||||
<h1>TaskFlow ran into a problem</h1>
|
|
||||||
<p>Nothing was lost. Reload the page to pick up where you left off.</p>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="btn btn-primary"
|
|
||||||
onClick={() => window.location.reload()}
|
|
||||||
>
|
|
||||||
Reload TaskFlow
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.props.children;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ErrorBoundary;
|
|
||||||
Loading…
Reference in New Issue
Block a user