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

298
Visualizações
How to use matchPatch with dynamic links on React Router v6

The path I'm trying to match is /threats/live/:id

We have a component where we usually render our breadcrumbs in and this was how they were built using react router v5:

const breadcrumbOptions = routes
  .filter((route) => matchPath(pathname, { path: route.link, exact: false }))
  .map((route) => ({
    ...route,
    label: route.breadCrumbtitle,
    onclick: undefined,
}))

For v6 this doesn't seem to work because it looks for :id in the url but instead finds the actual id.

I've tried the following but it still didn't work for me

const breadcrumbOptions = routes
  .filter((route) =>
    matchPath(
      { path: pathname, caseSensitive: false, end: false },
      route.link
    )
  )
  .map((route) => ({
    ...route,
    label: route.breadcrumbTitle,
    onclick: undefined,
}))
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I think that in v6 the function parameters of matchPath were reversed.

Could you try to do

matchPath(route.link, pathname)

instead?

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