Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

218
Visualizações
react nested routes default path blank page

How can I make the parent path render a default outlet in react router v6 nested routes? As you can see in the example I want to make "/dashboard" path take me to "/dashboard/home" by default.

For now it's just rendering a blank screen in the Outlet.

<Route path={"dashboard"} element={<Dashboard />}>
  <Route path={"home"} element={<Home />} />        
  <Route path={"users"} element={<Users />} />        
</Route>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can render an Index route to render some content when the path equals that of the parent route.

Example:

<Route path="dashboard" element={<Dashboard />}> // "/dashboard/*"
  <Route index element={/* some content */} />   // "/dashboard"
  <Route path="home" element={<Home />} />       // "/dashboard/home"
  <Route path="users" element={<Users />} />     // "/dashboard/users"
</Route>

If you want a specific nested route to be a "default" then either render it again as the index route or render a redirect to it.

Examples:

<Route path="dashboard" element={<Dashboard />}>
  <Route index element={<Home />} />
  <Route path="home" element={<Home />} />
  <Route path="users" element={<Users />} />
</Route>

or

<Route path="dashboard" element={<Dashboard />}>
  <Route index element={<Navigate to="home" replace />} />
  <Route path="home" element={<Home />} />
  <Route path="users" element={<Users />} />
</Route>
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda