File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments