Skip to content

Commit 3f28d67

Browse files
committed
bug fix
1 parent 45db44b commit 3f28d67

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/components/appRouter.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,14 @@ const recursiveRoutes = (
5555
Component
5656
);
5757
} else {
58-
acc[matchedIndex]["Component"] = Component.default;
58+
if (acc[matchedIndex]?.["children"]) {
59+
acc[matchedIndex]["children"]?.push({
60+
index: true,
61+
Component: Component.default,
62+
});
63+
} else {
64+
acc[matchedIndex]["Component"] = Component.default;
65+
}
5966
}
6067
};
6168

@@ -72,8 +79,6 @@ const allRoutes = Object.entries(routes).reduce(
7279
.split("/")
7380
.filter(Boolean);
7481

75-
console.log(routePath, "routePath");
76-
7782
recursiveRoutes(routePath, acc, Component);
7883
return acc;
7984
},
@@ -99,8 +104,6 @@ export const AppRouter = ({ router = createBrowserRouter }) => {
99104
});
100105
const elements = [...allRoutes, catchAllRoute] satisfies RouteObject[];
101106

102-
console.log(elements, "elements");
103-
104107
return <RouterProvider router={router(elements)} />;
105108
};
106109

0 commit comments

Comments
 (0)