Skip to content

Commit 63fd29e

Browse files
committed
feat(*): prefetch Home, About and Qrcode pages
1 parent fa2b468 commit 63fd29e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/components/Drawer.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,26 +72,29 @@ const SidebarContent: React.FunctionComponent<{
7272
t: i18next.TranslationFunction;
7373
closeDrawer: () => void;
7474
}> = ({ t, closeDrawer }) => {
75+
// only add prefetch in prod (not in test, it will fail) @todo, mock router on the testing side
76+
const prefetchProps =
77+
process.env.NODE_ENV === "production" ? { prefetch: true } : {};
7578
return (
7679
<SidebarContentWrapper>
7780
<h3>Menu</h3>
7881
<ul>
7982
<li className="home">
80-
<Link href={{ pathname: "/" }} as="/">
83+
<Link href={{ pathname: "/" }} as="/" {...prefetchProps}>
8184
<a onClick={closeDrawer}>
8285
<span>{t("common-label-home")}</span>
8386
</a>
8487
</Link>
8588
</li>
8689
<li className="about">
87-
<Link href={{ pathname: "/about" }} as="/about">
90+
<Link href={{ pathname: "/about" }} as="/about" {...prefetchProps}>
8891
<a onClick={closeDrawer}>
8992
<span>{t("common-label-about")}</span>
9093
</a>
9194
</Link>
9295
</li>
9396
<li className="qrcode">
94-
<Link href={{ pathname: "/qrcode" }} as="/qrcode">
97+
<Link href={{ pathname: "/qrcode" }} as="/qrcode" {...prefetchProps}>
9598
<a onClick={closeDrawer}>
9699
<span>{t("common-label-show-qrcode")}</span>
97100
</a>

0 commit comments

Comments
 (0)