after browsing for a while on the internet I could not figure out why my nested routes do not work.
index.js
<BrowserRouter>
12 <Navbar />
13 <App />
14 </BrowserRouter>
App.js
<>
<Routes>
<Route path="/" element={<Home />}>
<Route path="auth" element={<AuthApp />} />
</Route>
</Routes>
<Outlet />
</>
authApp.js
6 const AuthApp = () => {
7 return (
8 <>
9 <Routes>
10 <Route path="login" element={<LoginRoute />} />
11 <Route path="register" element={<RegisterRoute />} />
12 </Routes>
13 <Outlet />
14 </>
15 );
>> 16 }
LoginRoute, Home and RegisterRoute are very simple elements that for now should just display an h1. The problem is that /auth/login and /auth/register do not work. The links should be correct (I also tried manually to enter the url)
<nav style={navStyle}>
<CustomNavLink to="/" routeName="Home" />
<CustomNavLink to="/auth/login" routeName="Login" />
<CustomNavLink to="/auth/register" routeName="Register" />
</nav>
Could someone spot the problem? Thank you in advance. Additional question: Everytime I hit the login and register links I seem to get two hits. This is the output I see in the console:
No routes matched location "/auth/login"
No routes matched location "/auth/login"
Could someone explain this as well?