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

117
Visualizações
react router is not mounting the component in a class-based component

So first let me put the ground of the question I have a Products listing page where I am trying to filter products using category

Note: I am not allowed to use any hook because I am inside the class-based component I am writing a test that has specifications I cant use a function-based component

<Route exact path="/:category" element={<ProductListing/>}/>

This is my route right now I have three categories(All, Clothes, Tech) and I am taking them from API so I cant create a separate route for the categories my problem is when I click on the links the URL change but the component not render itself please help how can i fix this bug with existing codebase

Here is how i am rendering my links

{this.state.categories.categories.map((item,index)=>(
              <NavLink key={index} to={`/${item.name}`} className={({ isActive }) => isActive? "active": ''}>{item.name[0].toUpperCase()+item.name.substring(1)}</NavLink>
            ))}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can use the below code in your component to get the values from the URL. const params = useParams() then based on your parameter you can have access to the value. let UrlValue = params.category;

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