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

198
Views
React : useState for arrays with or without arrow function

I have an array declared like this :

const [myArray,setMyArray] = useState([]);

I want to add a value in myArray and I found two methods for that:

Solution1: setMyArray([...myArray,value]);

Solution2: setMyArray(myArray => [...myArray,value]);

I read that these two solutions are not exactly the same and can give different results in some case. Can you please explain to me the exact difference between the two in a simple way?

about 4 years ago · Juan Pablo Isaza
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!