Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

236
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda