feat: make 404 route faster

This commit is contained in:
tzhangchi
2023-02-06 22:36:40 +08:00
parent 9548cc1ed1
commit 4fed0de502

View File

@@ -67,8 +67,8 @@ const App = ({ Component, pageProps }: AppPropsWithLayout) => {
};
const AppDefender = ({ children }: PropsWithChildren) => {
const { synced } = useAppState();
const router = useRouter();
const { synced } = useAppState();
useEffect(() => {
if (router.asPath === '/') {
@@ -76,6 +76,11 @@ const AppDefender = ({ children }: PropsWithChildren) => {
}
}, [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>;
};