Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

242
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda