Reputation: 67
Hey Guys fairly Simple Question, i got this bit of code:
<Switch>
<Route component={TodoEdit} path="/app/edit/:id " />
<Route component={TodoDetails} path="/app/:id " />
<Route component={TodoApp} exact path="/app" />
<Route component={Home} exact path="/" />
</Switch>
The Bottom 2 components works fine, i can switch between them etc, the upper 2 don't, the one with the parameters, when i enter the id to go into details it doesn't render for some reason,
the URL does change to the correct one.
any solutions?
Upvotes: 0
Views: 45
Reputation: 251
Rearrange your routes to match the more specific ones first and then the variable ones. Something like the following :
<Route component={Home} exact path="/" />
<Route component={TodoApp} exact path="/app" />
<Route component={TodoEdit} exact path="/app/edit/:id" />
<Route component={TodoDetails} exact path="/app/:id" />
Upvotes: 1