feat: add error boundary
This commit is contained in:
20
src/components/base/base-error-boundary.tsx
Normal file
20
src/components/base/base-error-boundary.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import { ErrorBoundary, FallbackProps } from "react-error-boundary";
|
||||
|
||||
function ErrorFallback({ error }: FallbackProps) {
|
||||
return (
|
||||
<div role="alert">
|
||||
<p>Something went wrong:(</p>
|
||||
<pre>{error.message}</pre>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const BaseErrorBoundary: React.FC = (props) => {
|
||||
return (
|
||||
<ErrorBoundary FallbackComponent={ErrorFallback}>
|
||||
{props.children}
|
||||
</ErrorBoundary>
|
||||
);
|
||||
};
|
||||
|
||||
export default BaseErrorBoundary;
|
||||
Reference in New Issue
Block a user