Skip to content

Commit

Permalink
feat(projects): props are supported just like normal components
Browse files Browse the repository at this point in the history
  • Loading branch information
mufeng889 committed Sep 8, 2024
1 parent 9a1aab2 commit c6d3d9d
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/route-core/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,13 @@ export function transformElegantRouteToReactRoute(
if (layout) {
const singleLevelRoute:RouteObject= {
path,
lazy: layouts[layout],
ErrorBoundary,
lazy: layouts[layout],
children: [
{
id:name,
index: true,
ErrorBoundary,
lazy: views[view],
handle: {
...meta
Expand Down Expand Up @@ -173,11 +174,16 @@ export function transformElegantRouteToReactRoute(
if (isView(component)) {
const viewName = getViewName(component);
if (props) {
reactRoute.lazy = async () => {
const data= (await views[viewName]()).Component as FunctionComponent
reactRoute.lazy = async () => {
const data = await views[viewName]()
reactRoute.ErrorBoundary=data.ErrorBoundary||ErrorBoundary
return {
Component: ()=>data(props) ,
ErrorBoundary: null
Component: ()=>{
const Component = data.Component as FunctionComponent
return Component(props)
},
loader: data.loader,
action: data.action,
}
}
} else {
Expand All @@ -201,16 +207,15 @@ export function transformElegantRouteToReactRoute(
reactRoute.children.unshift({
index: true,
ErrorBoundary,
loader: () => redirectTo(defaultRedirectPath),
...rest
});
}else if (redirect) {
reactRoute.loader=()=>redirectTo(redirect)
}
if (loader) {
reactRoute.loader = () => loader
}
if (layout) {
Expand Down

0 comments on commit c6d3d9d

Please sign in to comment.