Answer the question
In order to leave comments, you need to log in
How to do react-router-dom routing correctly?
There are 2 containers in App.jsx
<Router>
<Switch>
<Route exact path="/" component={Main} />
<Route path="/auth" component={Auth} />
</Switch>
</Router>
<main>
<Layout>
<Sidebar />
<Switch>
<Route path="/rigs" render={() => <h1>hello</h1>} />
</Switch>
</Layout>
</main>
Answer the question
In order to leave comments, you need to log in
Your root route has the exact property, which means that the transition to it will be only if the path exactly matches /. The /rigs path will not render the Main component.
You can solve the problem like this:
<Switch>
<Route path="/auth" component={Auth} />
<Route path="/" component={Main} />
</Switch>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question