From 1cdc3bc0be395d9b781730b09ba92a2360929842 Mon Sep 17 00:00:00 2001 From: wang <1509326266@qq.com> Date: Mon, 26 Aug 2024 22:52:31 +0800 Subject: [PATCH] fix(projects): fixed hook not being used in routing files with parameters & component layout appears undefined --- src/route-core/const.ts | 7 +++++-- src/route-core/transform.ts | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/route-core/const.ts b/src/route-core/const.ts index a646f0c..2979ec4 100644 --- a/src/route-core/const.ts +++ b/src/route-core/const.ts @@ -121,8 +121,11 @@ export const generatedRoutes: GeneratedRoute[] = []; - if (config.layout||oldRoute.layout) { - updatedRoute.component = 'layout.'+ config.layout||oldRoute.layout; + + if (config.layout || oldRoute.layout) { + const layout = config.layout || oldRoute.layout; + + updatedRoute.component = `layout.${layout}`; }else if (oldRoute.component && component) { if (isFirstLevel) { const { layoutName: oldLayoutName } = resolveFirstLevelRouteComponent(oldRoute.component); diff --git a/src/route-core/transform.ts b/src/route-core/transform.ts index f3c6aba..cc67380 100644 --- a/src/route-core/transform.ts +++ b/src/route-core/transform.ts @@ -176,7 +176,7 @@ export function transformElegantRouteToReactRoute( reactRoute.lazy = async () => { const data= (await views[viewName]()).Component as FunctionComponent return { - element: data(props) , + Component: ()=>data(props) , ErrorBoundary: null } }