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

263
Vistas
What is the diff between this two arrow functions?

Basically, I don't understand why the second arrow function works, and first doesn't.

    //this one doesnt
    this.setState = () => {
            text: e.target.value,
        };
  
    //this one works
    this.setState(() => ({
            text: e.target.value,
        }));
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

The first one is an assignment the second one performs execution.

about 4 years ago · Juan Pablo Isaza Denunciar

0

The first one assigns the arrow function to this.setState and since there is an existing function called setState on this, it'll be overwritten by your arrow function.

The second one passes the arrow function as an argument to setState and setState will call the function you just passed at some point in its execution.

You can refer to the documentation to get a better idea of what setState does.

https://reactjs.org/docs/react-component.html#setstate

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