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

323
Visualizações
React.PureComponent - Why is this not implemented in React by default?

I have read about the differences between the Component and PureComponent classes of React and understood that PureComponent does the shallow comparisons of props and state in order to efficiently manage the renderings. Here are few questions,

  1. If the PureComponent optimizes renderings by avoiding unnecessary re-renders, Why doesn't it come By Default in the React (may be by implementing the handling of shouldComponentUpdate() in the Component class itself as React is all about efficiently updating the DOM).

  2. When do someone want to re-render a page even when the props and state remains unchanged, i.e. when to use Component over PureComponent?

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

0

Because doing the shallow props and state diff is not free, it requires a (tiny amount of) work. Since React already diffs with the DOM and only changes what you've changed in your re-rendered version (if anything), it's already doing one diff. Doing two (diffing the props and state, and then diffing w/the DOM) is sometimes useful (if they're unlikely to have changed), sometimes not (if they're very likely to have changed). So you can use PureComponent (or implement shouldComponentUpdate) if you think it will be useful, and not if you don't.

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