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

135
Vistas
React Component or Elements not showing in Router

So I was trying to make a website with a main page and a login page (and maybe more in the future) in React js.

I have two routes, one route that shows the login screen and another one that shows the main screen.

Now the problem is that the Login component shows, but the MainScreen does not. (When I paste "http://localhost:3000/home/" in the URL bar in the browser, it still shows the Login component)

Here is my code that I have inside App.js:

return (
    <div className="App">
    <Router>    
        <Switch>
          <Route path="/" >
              <LoginScreen />
          </Route>
          <Route path="/home" >
            <MainScreen />
          </Route>
        </Switch>
      </Router>
    </div>
  );
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Because the condition of your first rout is being met and rendered.

add EXACT and it should work.

return (
    <div className="App">
    <Router>    
        <Switch>
          <Route exact path="/" >
              <LoginScreen />
          </Route>
          <Route exact path="/home" >
            <MainScreen />
          </Route>
        </Switch>
      </Router>
    </div>
  );
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