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

86
Visualizações
React Router v6 warning on nested index routes

The following code (codesandbox) produces this warning when the root url is navigated to:

You rendered descendant (or called useRoutes()) at "/" (under <Route path="">) but the parent route path has no trailing "*"...

However, no warning is issued if I navigate to "/post/blah".

import { Routes, Route} from "react-router-dom";



const StreamPage = () => (
  <>
        <Routes>
            <Route index element={<div /> } />
            <Route path="post/:subslug/*" element={<div /> }/>
        </Routes>

      <Routes>
        <Route index element={<div />} />
        <Route path="post/:subslug/*" element={<div />} />
      </Routes>
  </>
)


export const App = () => (
      <Routes>
        <Route path="/" >
          <Route path="post/*" element={<StreamPage  />} />
          <Route index element={<StreamPage />} />
        </Route>
      </Routes>
  )

I know, I could fix the code by merging the two Routes blocks in StreamPage but I'm asking if this is expected behavior and if so what part of the react-router usage contract/API I'm violating? For instance, am I not allowed to have don't have sibling index routes under an index route? If I don't understand when/why this warning is produced I won't be able to avoid it in the future.

(related to this earlier question)

about 4 years ago · Juan Pablo Isaza
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