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

133
Views
React adding to array performance with useState vs push

When I add elements to an array and want to lead to a render of components using that array, I have to use the useState hook and the spread operator, if I'm not mistaken:

setTestArray(array => [...array, data]);

When I want to add an element in normal JavaScript, I just use push. Isn't it much faster to just push an element to an array? Isn't there a way to avoid this problem and e.g. push an element and then "say to React" that you want the components using that array to rerender? Are there any other ways to add elements to an array/set that have a better performance?

Just getting started with react, so maybe I have overlooked something here :/

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

React states are immutable, so if you want to change state you have to set the state again. I'm sure under the hood, react does some smart diffing that is able to re-render things smartly.

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!