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

215
Views
React.js "let" v.s "const" v.s "var" v.s "state"

I'm learning React.js recently,

and I have some questions,

  1. As we know setState is asynchrony, if we don't use js framework, we will use let const or var to setting variable, it's synchrony, but why we should much more use state instead of let const var to setting variable in React.js?

  2. Some scenario I use state but it cannot work very well to my WebApp, so that I try to use let to set my variable, and it can work very well, but I think if I use let rather than state, is it not a good idea because I wasted React.js advantage?

thank you for your help :>

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Simply, in most cases we use state if we will use it in the UI ( in the JSX mockups ), as when it updates with setState the UI updates, this doesn't happen with normal javascript variables as it re-initializes when the component updates.

That's besides that other hooks, just updates regard to stateful dependencies only, like useEffect, useMemo, useCallback.

about 4 years ago · Santiago Gelvez 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!