Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

135
Vistas
Need some clarification on getDerivedStateFromProps when reacting to toggling props

In the case below, where I need to update the state if some mode was enabled, is there any performance implication of unconditionally copying props.isScaffoldingMode to the state?

I wonder, if I should use didUpdate for this case or copy the prop only when it changes.

I am unsure if getDerivedStateFromProps causes a full re-render, like setting the state in didUpdate would in this case.

Thank you for your time.

  static getDerivedStateFromProps(nextProps, prevState) {
    let newState = { prevIsScaffoldingMode: nextProps.isScaffoldingMode };
   
    if (nextProps.isScaffoldingMode && !prevState.prevIsScaffoldingMode) {
      const scaffoldingState = StandardItemComponent.prepareScaffoldingMode(nextProps);
      newState = { ...newState, ...scaffoldingState };
    }
      return newState;
    }
about 4 years ago · Juan Pablo Isaza
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 Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda