File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -52,13 +52,17 @@ interface RawNodeDatum {
5252 children ?: RawNodeDatum [ ]
5353 errorBoundary : { hasErrorBoundary : boolean ; errorBoundaryId : string | null }
5454}
55-
55+ const routeMap = new Map ( )
5656const constructTree = ( routes : any , parentId ?: string ) : RawNodeDatum [ ] => {
5757 const nodes : RawNodeDatum [ ] = [ ]
5858 const routeKeys = Object . keys ( routes )
5959 for ( const key of routeKeys ) {
6060 const route = routes [ key ]
6161 if ( route . parentId === parentId ) {
62+ if ( routeMap . get ( key ) ) {
63+ nodes . push ( routeMap . get ( key ) )
64+ return nodes
65+ }
6266 const url = convertReactRouterPathToUrl ( routes , route )
6367 const node : RawNodeDatum = {
6468 name : url ,
@@ -69,6 +73,7 @@ const constructTree = (routes: any, parentId?: string): RawNodeDatum[] => {
6973 errorBoundary : findParentErrorBoundary ( route ) ,
7074 children : constructTree ( routes , route . id ) ,
7175 }
76+ routeMap . set ( key , node )
7277 nodes . push ( node )
7378 }
7479 }
You can’t perform that action at this time.
0 commit comments