I have some nested routes:
<Routes>
<Route path="components" element={<Components />}>
<Route path="alert" element={<Alerts />} />
<Route path="button" element={<Buttons />} />
<Route path="chip" element={<Chips />} />
</Route>
</Routes>
I have an <Outlet />
setup in <Components>
and the nested routes work as expected.
/components/alert
/components/button
/components/chip
If someone visits /components
, I would like to redirect them to /components/alert
. Previously using v5 I would use a <Redirect to="/components/alert">
component. How can I achieve this using v6?
I tried using the new <Navigate>
component with a wildcard path like this:
<Route path="components" element={<Components />}>
...
<Route path="*" element={<Navigate to="alert" replace />} />
</Route>
But this didn't seem to work.