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

114
Visualizações
React-router with multiple user paths

I'm developing a PWA in React (with react-router) that includes a Shell with 3 tabs. Each of these tabs contains several screens. This separates the application into 3 completely separate trees.

What I have: Each of the 3 Shell buttons is linked to the first screen in the associated tree (thanks to history.push(): history.push('/login') for the first button, history.push('/') for the second one and history.push('/my') for the third one). When the user clicks on one of the 3 tabs, it logically takes him to the first screen of the tree structure.

What I would like: When the user clicks on one of the Shell buttons, it takes them to the last screen he visited within the tree associated to that button. An example:

  1. The user opens the application and goes to tab 1. This takes him to the '/login' page
  2. From this page, he clicks on "Create an account", which brings him to the '/registration' page (still in the same tree)
  3. He clicks on the second button of the Shell, that makes him change tree and go on '/'
  4. He clicks again on the first Shell button, and goes back to '/registration' instead of '/login

What I can do, but...: I can create a context that keeps the last visited url for each tree, and retrieve it when clicking on one of the Shell buttons to bring the user to the right place. It works, no problem. However, I have to add the context update for each new page I create. Not great... And I feel like it's a bit hacky and "handcrafted". A classic use case like this should surely be handled by react-router, or in a simpler way.

Do you have any idea of the right way to achieve that? Thank you very much!

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