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

169
Vistas
Reactjs Conditionally hide component

App.js renders an element from NewNav.tsx. I an trying to conditionally hide the element in App.js. For example I want to hide the element only on a route "/check".

App.js

render() {
     return (
           <NewNav />
)
}

NewNav.tsx

return (
    <Navbar>
    ......
    ......
    ......
    </Navbar>
)
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

This will hide <NewNav /> component when route is /check

render() {
     return (
         window.location.pathname.split('/')[1] !== "check" && <NewNav />
)
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

If your goal is to display components based on the route in the url (/check, /login, /register, etc), then you'll need react-router-dom for that. It's better this way than manually checking for the url pathname.

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