Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

142
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda