feat: add error boundary
makes crashes graceful
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import type { AppProps } from 'next/app';
|
||||
import usePageLoading from '../hooks/usePageLoading';
|
||||
import ProgressBar from '../components/loaders/ProgressBar';
|
||||
import ErrorBoundary from '../components/error/ErrorBoundary';
|
||||
import ThemeProvider from '../context/theme-context';
|
||||
|
||||
import '../styles/main.scss';
|
||||
import { useRouter } from 'next/router';
|
||||
|
||||
const ModifiedApp = ({ Component, pageProps }: AppProps) => {
|
||||
const { isPageLoading, key } = usePageLoading();
|
||||
@@ -12,10 +12,12 @@ const ModifiedApp = ({ Component, pageProps }: AppProps) => {
|
||||
return (
|
||||
<ThemeProvider>
|
||||
{isPageLoading && <ProgressBar />}
|
||||
<Component
|
||||
{...pageProps}
|
||||
key={key} /* passing key to force react to remound components */
|
||||
/>
|
||||
<ErrorBoundary>
|
||||
<Component
|
||||
{...pageProps}
|
||||
key={key} /* passing key to force react to remount components */
|
||||
/>
|
||||
</ErrorBoundary>
|
||||
</ThemeProvider>
|
||||
);
|
||||
};
|
||||
|
Reference in New Issue
Block a user