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

138
Views
if a useState holds a string, does setting it to an identical string trigger downstream dependencies?
const [stuff, set_stuff] = useState("a")


...

set_stuff("a")

when set_stuff("a") is run, will it trigger downstream?

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

0

As per the documentation (of which another part was cited in the comments),

If you update a State Hook to the same value as the current state, React will bail out without rendering the children or firing effects. (React uses the Object.is comparison algorithm.)

which means that no, setting the state to the same value it had should not trigger a re-render or re-computing any dependents; set_stuff(stuff) should generally be a no-op. Of course, a re-render may trigger at the same time for unrelated reasons.

Also, remember that Object.is compares objects by identity (so-called ‘shallow’ equality), which means updating the state to an object with the same properties as the old one will not be considered identical and will trigger a re-render, even if the programmer considers the new state equivalent.

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!