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

164
Visualizações
Router is appending the path at the end

I have many component in react page. in my router file I have used them like below.

  <SecureRoute path="/new-inventory">
            <Inventory />
        </SecureRoute>

        <SecureRoute path="/list-inventory">
            <ListInventory />
        </SecureRoute>


        <SecureRoute exact path="/:id/edit" component={EditInventory} />

below path gets called within the component

   <SecureRoute exact path="/:id/edit" component={EditInventory} />

I am using below anchor tag.

<a href={/${props.inventory.id}/edit}>

path in browser gets generated like this

http://localhost:4200/36917491-4ef5-4fa2-87aa-c921986f94d1/edit

now if I click on otther tab for ex inventory then instead of coming url like http://localhost:4200/inventory it comes like http://localhost:4200/36917491-4ef5-4fa2-87aa-c921986f94d1/edit/inventory

means path gets appended instead of replacing. what should I do?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Instead of using anchor tags use Link that comes with react-router. anchor tags will trigger page reload while Link do not.

import { Link } from "react-router-dom";

<Link to="/list-inventory">Inventory</Link>list-inventory
about 4 years ago · Juan Pablo Isaza Relatório
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