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

128
Vistas
Do state setters get recreated when the component re-render?

A function defined in some component, gets recreated on every render, if it's not memoized with some useCallback, that's what I've learned. Does this apply to state setters, like setState in below component?

To my knowledge, foo in below component is typically a function that gets recreated on every re-render.

import { useState } from "react";

export default function App() {
  const [state, setState] = useState(true);
  const foo = () => console.log("Hello Word");
  return (
    <div>
      <button onClick={() => setState(!state)}>Change state</button>
    </div>
  );
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

No, the dispatch function is guaranteed to always stay the same hence why you don't need to place it in the dependency array. "React guarantees that setState function identity is stable and won’t change on re-renders." React docs

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