0

Can anyone help me if there is a way to get redirected to /home whenever I access the root URL? Or at least have the Home link active when I'm in the root URL. I have this react-router setup so I can have my navigation at the top in any routes.

Everything is working great except the fact that the Home is not getting the active class(thus not receiving the active styling) even tho it is the index path of the parent route.

<Routes>
  <Route path='/' element={<Navigation />}>
    <Route index element={<Home />} />
    <Route path='home' element={<Home />} />
    <Route path='tables' element={<Tables />} />
    <Route path='orders' element={<Orders />} />
  </Route>
</Routes>

I'm a self taught and pretty new to react and web dev in general. I've been reading the docs but I'm still quite lost.. hopefully there's an answer that would not involve me rearranging my Route nest setup because it will be like starting from scratch due to how my component are placed

And yes I'm using the latest version of react and react-router-dom

I tried to use Redirect and Navigate hooks from react-router-dom but the results are either me getting errors or there's no redirect happening at all.

0 Answers0