feat: add reviews, notifications, notes and account hardening
This commit is contained in:
31
components/ui/ErrorBoundary.tsx
Normal file
31
components/ui/ErrorBoundary.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
import React, { ReactNode } from 'react';
|
||||
|
||||
interface ErrorBoundaryState {
|
||||
hasError: boolean;
|
||||
}
|
||||
|
||||
export class ErrorBoundary extends React.Component<{ children: ReactNode }, ErrorBoundaryState> {
|
||||
declare props: Readonly<{ children: ReactNode }>;
|
||||
state: ErrorBoundaryState = { hasError: false };
|
||||
|
||||
static getDerivedStateFromError(): ErrorBoundaryState {
|
||||
return { hasError: true };
|
||||
}
|
||||
|
||||
componentDidCatch(error: Error, info: React.ErrorInfo) {
|
||||
console.error('Unhandled application error', error, info);
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.state.hasError) {
|
||||
return <main className="wrap page">
|
||||
<div className="empty">
|
||||
<h1>Algo deu errado</h1>
|
||||
<p>Não foi possível exibir esta página. Recarregue para tentar novamente.</p>
|
||||
<button className="btn" type="button" onClick={() => window.location.reload()} style={{ marginTop: 20 }}>Recarregar página</button>
|
||||
</div>
|
||||
</main>;
|
||||
}
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user