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

185
Vistas
How setState provides previous state in React.Component

I have already checked the setState() and React.Component class source code of the React official document. Nevertheless, the question about the prevState passed to the parameter of the setState() function has not been resolved. Developers know that when you declare a class-type component and inherit React.Component, you can change the state through setState internally and use prevState without this.state or declarer. What I am curious about is, whether it is possible to bring the first parameter inside the state of the code below to a precarious state?

class App extends React.Component {
  state = {
    count: 0,
  }

  setState((prevState) => ({...prevState, count: prevState.count + 1}));

  render() {
    return <div>{this.state.count}</div>
  }

}
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