refactor: project configuration

This commit is contained in:
Tristan Yang
2023-05-15 16:46:50 +08:00
parent 187ffd24d1
commit 20b907aae4
293 changed files with 991 additions and 964 deletions
+27
View File
@@ -0,0 +1,27 @@
import React, { ReactNode } from 'react';
import { ErrorBoundary } from "react-error-boundary";
type FallbackProps = {
error: Error,
resetErrorBoundary: (...args: Array<unknown>) => void
}
function ErrorFallback({ error, resetErrorBoundary }: FallbackProps) {
return (
<div role="alert" className='text-lg text-red-600'>
<p>Something went wrong:</p>
<pre>{error.message}</pre>
<button onClick={resetErrorBoundary}>Try again</button>
</div>
);
}
type Props = {
children: ReactNode
}
const ErrorCatcher = ({ children }: Props) => {
return (
<ErrorBoundary FallbackComponent={ErrorFallback}>{children}</ErrorBoundary>
);
};
export default ErrorCatcher;