• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

203
Vistas
Understanding React Rendering

It seems that React components always run their render method when their parent component renders, even if no state or props changed for the child component, even if the child component has no state or props.

Is this supposed to be? Is there any inefficiency in this? Switching the child component to a PureComponent fixes this, and the child component will not reRender. Should I favor PureComponents over regular Components?

over 3 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

If you are wanting to control what makes a component rerender then you should be using shouldComponentUpdate which can be used on all react components unless they are stateless functional components. The PureComponent basically uses a shouldComponentUpdate automatically and does a shallow check on past and current props/state and if there was a change it will rerender.

Sometimes you might be dealing with more complex data structures and want to be in control of the shouldComponentUpdate yourself, in that case just follow the life cycle method instructions here.

https://facebook.github.io/react/docs/react-component.html#shouldcomponentupdate

Here is also the info for PureComponent

https://facebook.github.io/react/docs/react-api.html#react.purecomponent

over 3 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda