Skip to content

Commit 63f7102

Browse files
committed
FIX: Potential navigation issue if links are added to guides
1 parent 360f542 commit 63f7102

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

packages/frontend/src/help/guide.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useParams } from "@solidjs/router";
2-
import { lazy } from "solid-js";
2+
import { createMemo, createResource } from "solid-js";
33
import { Dynamic } from "solid-js/web";
44

55
import { guidesList } from "./guides";
@@ -14,19 +14,24 @@ export default function GuideHelpPage() {
1414
export function GuideHelp(props: { id?: string }) {
1515
// Note that guide should never be undefined, due to existingGuideFilter
1616
// in routes.ts
17-
const guide = guidesList.find((item) => item.id === props.id);
17+
const guide = createMemo(() => guidesList.find((item) => item.id === props.id));
18+
19+
const [module] = createResource(
20+
() => props.id,
21+
async (guideId) => {
22+
return await import(`./guide/${guideId}.mdx`);
23+
},
24+
);
1825

1926
return (
2027
<>
2128
<h1>
22-
<a href="/help/guides/">Guides</a> / {guide?.title}
29+
<a href="/help/guides/">Guides</a> / {guide()?.title}
2330
</h1>
2431
<p>
25-
<i>{guide?.description}</i>
32+
<i>{guide()?.description}</i>
2633
</p>
27-
<Dynamic component={helpGuideContent(props.id)} />
34+
<Dynamic component={module().default} />
2835
</>
2936
);
3037
}
31-
32-
const helpGuideContent = (id?: string) => lazy(() => import(`./guide/${id}.mdx`));

0 commit comments

Comments
 (0)