Skip to content

Commit 9a5385f

Browse files
committed
layout render issue fixed
1 parent 30490e8 commit 9a5385f

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@
5555
"lucide-react": "^0.523.0",
5656
"tailwindcss": "^4.1.10"
5757
}
58-
}
58+
}

src/package/components/appRouter.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ const recursiveRoutes = (
8181
LoadingComponent={LoadingComponent}
8282
/>
8383
);
84-
if (acc[matchedIndex]?.["children"]) {
84+
const layoutExist = acc[matchedIndex]?.["Component"];
85+
86+
if (acc[matchedIndex]?.["children"] || layoutExist) {
87+
acc[matchedIndex]["children"] = acc[matchedIndex]?.["children"] || [];
8588
acc[matchedIndex]["children"]?.push({
8689
index: true,
8790
Component: RouterComponent,
@@ -121,7 +124,9 @@ export const useAppRouter = () => {
121124
allRoutes.forEach((element: RouteObject) => {
122125
if (element.path === "/") {
123126
element.ErrorBoundary = ErrorElement;
124-
element?.children?.push(catchAllRoute);
127+
if (element?.children?.findIndex((r) => r.path === "*") === -1) {
128+
element?.children?.push(catchAllRoute);
129+
}
125130
}
126131
});
127132
return allRoutes satisfies RouteObject[];

0 commit comments

Comments
 (0)