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

180
Visualizações
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 à 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