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

177
Vistas
Benefit of using OldState / PrevState in React?

I don't understand completely the benefit of using oldState / prevState. In the tutorial the code was changed from this :

  const DeleteClick = (id) => {
    SetMylist(Elems.filter(Elem => id !== Elem.id))
  }

to this :

  const DeleteClick = (id) => {
    SetMylist(OldElems => {
      return OldElems.filter(Elem => id !== Elem.id)
    })
  }

The guy said in the tutorial that if we use oldState / prevState then we get the most recent ( updated ) version of the state variable.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You will be able to learn what the difference between setState and prevState is and what the benefit of prevState is from https://www.delftstack.com/howto/react/react-setstate-prevstate/#:~:text=setState%20is%20the%20primary%20method,that%20component%2C%20we%20use%20this.

about 4 years ago · Juan Pablo Isaza 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 Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda