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

172
Visualizações
Why does the React component render?

I have a rather complicated React app. The problem I am facing is that when a link is click on in the navbar the navbar re-renders. Obviously this is a sign that the app is doing unnecessary rendering. The navbar exists in a "header" component. This "header" should be fixed. But it is getting called numerous times. What is the recommended way to tell WHY a component renders. I can think of numerous reasons and I would like to start eliminating them to cut down on unnecessary renders. The component could be

  • Changing internal state (via useState)
  • useEffect
  • subscribed to "external" state via useSelect
  • have props change

There may be others. How do I tell WHY a component renders?

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

0

There (apparently) is no easy way to tell why a component renders, probably because it inherently requires deep comparison (at least to cover all cases), which can be an expensive operation.

But there are many tools and workarounds.

  • use the React dev tools (helps, but doesn't show why something renders)
  • temporarily add a useEffect to observe specific values
  • write a hook that can observe several specific values at once
  • install some node package
  • check out trace-why-a-react-component-is-re-rendering
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