Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

261
Views
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 answers
Answer question

0

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

about 4 years ago · Juan Pablo Isaza Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!