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

772
Visualizações
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 à 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