feat: add error boundary

This commit is contained in:
GyDi
2022-11-19 01:22:19 +08:00
parent 166d7ba1cf
commit a1f819a458
5 changed files with 54 additions and 20 deletions

View 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;