Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit c942808

Browse files
committed
fix: fix custom components loading
1 parent 2ef2cc1 commit c942808

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

framework/react/bootstrap.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ export default async function bootstrap({ baseUrl, defaultLocale, locales, route
2020
const ssrDataEl = document.querySelector('#ssr-data')
2121
const routing = new Routing(routes, baseUrl, defaultLocale, locales)
2222
const [url, pageModuleTree] = routing.createRouter()
23-
const sysComponents: Record<string, ComponentType> = {}
23+
const customComponents: Record<string, ComponentType> = {}
2424
const pageComponentTree: { url: string, Component?: ComponentType }[] = pageModuleTree.map(({ url }) => ({ url }))
2525

2626
await Promise.all([...preloadModules, ...pageModuleTree].map(async mod => {
2727
const { default: C } = await importModule(baseUrl, mod)
2828
switch (mod.url.replace(reModuleExt, '')) {
29-
case '/404 ':
30-
sysComponents['E404'] = C
29+
case '/404':
30+
customComponents['E404'] = C
3131
break
32-
case '/app ':
33-
sysComponents['App'] = C
32+
case '/app':
33+
customComponents['App'] = C
3434
break
3535
default:
3636
const pc = pageComponentTree.find(pc => pc.url === mod.url)
@@ -53,7 +53,7 @@ export default async function bootstrap({ baseUrl, defaultLocale, locales, route
5353
{
5454
url,
5555
routing,
56-
sysComponents,
56+
customComponents,
5757
pageComponentTree
5858
}
5959
)

framework/react/root.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ import { createPageProps, importModule, isLikelyReactComponent } from './util.ts
1111
export default function AlephAppRoot({
1212
url,
1313
routing,
14-
sysComponents,
14+
customComponents,
1515
pageComponentTree,
1616
}: {
1717
url: RouterURL
1818
routing: Routing
19-
sysComponents: Record<string, ComponentType<any>>
19+
customComponents: Record<'E404' | 'App', ComponentType<any>>
2020
pageComponentTree: { url: string, Component?: any }[]
2121
}) {
2222
const [e404, setE404] = useState<{ Component: ComponentType<any>, props?: Record<string, any> }>(() => {
23-
const { E404 } = sysComponents
23+
const { E404 } = customComponents
2424
if (E404) {
2525
if (isLikelyReactComponent(E404)) {
2626
return { Component: E404 }
@@ -30,7 +30,7 @@ export default function AlephAppRoot({
3030
return { Component: E404Page }
3131
})
3232
const [app, setApp] = useState<{ Component: ComponentType<any> | null, props?: Record<string, any> }>(() => {
33-
const { App } = sysComponents
33+
const { App } = customComponents
3434
if (App) {
3535
if (isLikelyReactComponent(App)) {
3636
return { Component: App }

0 commit comments

Comments
 (0)