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

237
Visualizações
React router order of routes, does it matter?

I set up my react router like this:

<Route exact path="/users">
    <component/>
</Route>
<Route exact path="/users/:id">
    <component/>
</Route>

And it wasn't working correctly (url was changing but content wasn't) after I changed the order of Route in my Routes.js (the one with :id first) it started working. Do it matters or there is other problem somewhere in my code?

about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

Yes you need to check

Route and Switch

<Switch> is unique in that it renders a route exclusively. In contrast, every <Route> that matches the location renders inclusively.

Read and explore more at https://reactrouter.com/web/api/Switch

about 4 years ago · Juan Pablo Isaza Relatório

0

Yes, nested routes should be above its parent.

So in the following code, about/user has to be above /about. If its beneath then only /about will render

<Route path='about/user' />
<Router path='about/' />
about 4 years ago · Juan Pablo Isaza Relatório

0

Basic React Router Setup

    <Router>
        <Switch>
          <Route path="/about">
            <About />
          </Route>
          <Route path="/users">
            <Users />
          </Route>
          <Route path="/">
            <Home />
          </Route>
        </Switch>
    </Router>
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