Answer the question
In order to leave comments, you need to log in
Nested routes in React Router 4. The 'user1/commit1' link fires the component for 'user1/'. How can this be done properly?
The link '/user1/commit1' triggers the component for '/user1/', not for 'user1/commit1/'
Code snippet:
<Switch>
<Route exact path="/" component={HomePage} />
<Route path="/:user" component={UserPage} />
<Route path="/:user/:commit" component={CommitPage} />
</Switch>
<Switch>
<Route exact path="/" component={HomePage} />
<Route exact path="/:user" component={UserPage} />
<Route path="/:user/:commit" component={CommitPage} />
</Switch>
Answer the question
In order to leave comments, you need to log in
How can this be fixed?
<Switch>
<Route exact path="/" component={HomePage} />
<Route path="/:user/:commit" component={CommitPage} />
<Route path="/:user" component={UserPage} />
</Switch>
What should be studied in order to understand the issue?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question