feat: make 404 route faster
This commit is contained in:
@@ -67,8 +67,8 @@ const App = ({ Component, pageProps }: AppPropsWithLayout) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const AppDefender = ({ children }: PropsWithChildren) => {
|
const AppDefender = ({ children }: PropsWithChildren) => {
|
||||||
const { synced } = useAppState();
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const { synced } = useAppState();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (router.asPath === '/') {
|
if (router.asPath === '/') {
|
||||||
@@ -76,6 +76,11 @@ const AppDefender = ({ children }: PropsWithChildren) => {
|
|||||||
}
|
}
|
||||||
}, [router]);
|
}, [router]);
|
||||||
|
|
||||||
|
// if you visit /404, you will see the children directly
|
||||||
|
if (router.route === '/404') {
|
||||||
|
return <div>{children}</div>;
|
||||||
|
}
|
||||||
|
|
||||||
return <div>{synced ? children : <PageLoading />}</div>;
|
return <div>{synced ? children : <PageLoading />}</div>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user