Answer the question
In order to leave comments, you need to log in
How to fix a bug in react-router ??
The situation is as follows: there is a root Switch with routes to pages, it has a Route Home in which there is a built-in switch in order to render nested pages in it.
ROOT SWITCH
<Switch>
Route exact path={'/'} component={Home} />
Route path={'/profile'} component={Profile} />
Route path={'/auth'} component={Auth} />
Route path={'/auth/login'} component={Login} />
Route path={'/auth/register'} component={Register} />
Route path={'/terms'} component={Terms} />
Route path={'/inbox'} component={Inbox} />
Route component={NotFound} />
</Switch>
< Header/>
<Switch>
<Route path={'/'} component={Latest} />
<Route path={'/users/:id'} component={User} />
<Route path={'/product/:id'} component={Product} />
<Route path={'/search'} component={Search} />
<Switch/>
<Footer/>
Answer the question
In order to leave comments, you need to log in
For example:
return (
<Switch>
<Route exact path="/(users/.+|product/.+|search)?" component={Home} />
{/* other routes */}
</Switch>
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question