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

771
Vistas
To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function (potential async issue)

Getting the following (common) message in my console:

Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.

This is a common question, I know, I've been trying to figure out where my specific problem is. Below are the original code (with the error) as well as my attempted fix (did not work, but made es-lint happy).

setData is a state hook, if that wasn't clear.

Original code:

  useEffect(() => {
    if (!isExisting) {
      const fetchData = async () => {
        const response = await refreshData();
        setData(response);
      };
      fetchData();
      // eslint-disable-next-line react-hooks/exhaustive-deps
    }
  }, []);

Attempted Fix:

  useEffect(() => {
    if (!isExisting) {
      const fetchData = async () => {
        const response = await refreshData();
        setData(response);
      };
      fetchData();
      // eslint-disable-next-line react-hooks/exhaustive-deps
    }
  }, [isExisting, refreshData]);
about 4 years ago · Juan Pablo Isaza
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