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

182
Vistas
Conditional routing using react-router-dom isn't working

So I have an issue where I am using conditional routing in an assignment and for some reason it's not returning the expected value so here is what the important part of the code looks like:

<Route
  path="/profile/:username?"
  element={<Profile />}
/>

However running like this keeps giving me an error that it couldn't find the page. When I checked out the useParams I found that instead of labeling the conditional username it would label it "*" and then have the full path in the output like this:

*:'/profile/dsamuelson'

yet when I take the question mark off then it labels the path correctly as username and gives me the page I want

username:'dsamuelson'

Does anyone have any idea why it's behaving like that. Literally every page I go to says that all you do is add the ? mark conditional lookback and it should work with or without the second field but it is just not working. Any help is greatly appreciated.

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