Skip to content
This repository has been archived by the owner on Apr 12, 2020. It is now read-only.

Svero is picking the wrong component #36

Closed
lud opened this issue Aug 6, 2019 · 2 comments
Closed

Svero is picking the wrong component #36

lud opened this issue Aug 6, 2019 · 2 comments

Comments

@lud
Copy link

lud commented Aug 6, 2019

With this code:

<Router>
  <Route path="/game/parties/:party_id" component={Party} />
  <Route path="/game/new-party" component={PartyCreate} />
  <Route path="/game" component={Dashboard} />
</Router>

When I load the page as /game, the Party component is initialized (with undefined as party_id.

resolveRoutes returns:

[
  {
    "matches": true,
    "params": {},
    "route": "/",
    "path": "/"
  },
  {
    "matches": false,
    "params": {},
    "route": "/",
    "path": "/"
  },
  {
    "key": "p23gll8y2o",
    "matches": true,
    "params": {},
    "route": "/game",
    "path": "/game"
  }
]

I know I can use a basePath for the moment, but I may have urls not starting with /game to handle.

What did I do wrong ?

@kazzkiq
Copy link
Owner

kazzkiq commented Aug 6, 2019

Try using the exact attribute:

<Router>
  <Route path="/game/parties/:party_id" component={Party} />
  <Route path="/game/new-party" component={PartyCreate} />
  <Route exact path="/game" component={Dashboard} />
</Router>

If that doesn't work, try putting /game route before all other routes, too.

@lud
Copy link
Author

lud commented Aug 18, 2019

Sorry for the late answer, I changed project, but thank you that is good to know.

@lud lud closed this as completed Aug 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants