0

I have a nested Switch and using Link from inside the child Switch to reach a link on the Parent return the url but won't actualy change the route.

      <Router>
    <Navigation />
    <Switch>
      <Route path="/admin">
        <Admin />
      </Route>
      <Route path="/">
        <Main />
      </Route>
    </Switch>
  </Router>



  <MainRouter>
    <Navigation />
    <Switch>
      <Route path="/" exact>
        <Home />
      </Route>
      <Route path="/about">
        <About />
      </Route>
    </Switch>
  </MainRouter>



  <AdminRouter>
    <Link to="/">Return to Home</Link> -> this won't work
    <Switch>
      <Route path="/admin" exact>
        <Dashboard />
      </Route>
      <Route path="/admin/reports" exact>
        <Reports />
      </Route>
    </Switch>
  </AdminRouter>

It only navigates to the Admin component.

  • Does this answer your question? [Trying to go back to "/" in react router?](https://stackoverflow.com/questions/49921290/trying-to-go-back-to-in-react-router) – Lith Aug 29 '21 at 21:18

0 Answers0