Saritasa/react-app-core

Injected RouteStore does not work properly inside switch route

Closed this issue · 0 comments

The reason of issue is that RouteStore wraps own routes into extra RouteShape with empty path. So if we use something like:

{
  isSwitch: true,
  childRoutes: [
    { injectToken: '1' },
    { injectToken: '2' },
  ],
}

Result after injecting stores will be:

{
  isSwitch: true,
  childRoutes: [
    { 
      childRoutes: [
        { path: 'name1', childRoutes: [/* routeStore1.routes */] },
      ],
    },
    { 
      childRoutes: [
        { path: 'name2', childRoutes: [/* routeStore2.routes */] },
      ],
    },
  ],
}

So switch always use 1st route.