question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Child routes with path="/" can't be matched

See original GitHub issue

I’m looking to group a very large amount of routes under a multi-tenant context such as https://acme.com/mytenant

This url should pull tenantName = mytenant and hit the / Route.

This works fine:

        <Route
          path="/:tenantName/"
          Component={loadable(() => import('./DashboardPage'))}
        />

But this does not:

<Route path="/:tenantName">
    <Route
      path="/"
      Component={loadable(() => import('./DashboardPage'))}
    />
</Route>

Are path props overrides or are they additive?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
taioncommented, Jan 24, 2019

okay, that’s totally a bug then. mind if i track it on this issue?

1reaction
taioncommented, Jan 24, 2019

Yes, they’re additive. The intent was that for the sake of understandability (and also not traversing the entire route tree every time), that it didn’t make a lot of sense for children to match if their parents didn’t. Note that you can have path-less routes, though, so you can write the above as something like:

<Route Component={MainComponent}>
    <Route path="/:tenantName" />
    <Route
      path="/"
      Component={loadable(() => import('./DashboardPage'))}
    />
</Route>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Navigation to child routes gives error "cannot match any routes"
Try this.router.navigate(['/dashboard/profile']);. and change your route as, const appRoutes: Routes = [ { path: '', component: ...
Read more >
Cannot match any routes for child paths · Issue #45659 - GitHub
It looks to me that you're missing pathMatch: 'full' in the configuration of the HomeComponent route; effectively hiding the contact-us route ...
Read more >
Router tutorial: tour of heroes - Angular
A wildcard route has a path consisting of two asterisks. It matches every URL. Thus, the router selects this wildcard route if it...
Read more >
Troubleshooting Angular routing - Medium
List routes with a static path first, followed by an empty path route, which matches the default route. The wildcard route comes last...
Read more >
Angular Router: Child Routes, Auxiliary Routes, Master Detail
What we are doing in this initial configuration is to map certain URL paths to Angular components: meaning that if there is a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found