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

149
Visualizações
How to call an async cleanup function?

How can I call an async cleanup function in useEffect?

useEffect(() => {
    return () => Voice.destroy().then(Voice.removeAllListeners);
  }, []);

The EffectCallback expects void, not Promise<void>

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can wrap the body in curly braces, because currently it returns the Promise (this is what happens when you omit the curly braces, a one line return), which makes your cleanup function return a Promise<void>. With curly braces, it will be just the body of the function and not an implied return statement:

useEffect(() => {
    return () => {
           Voice.destroy().then(Voice.removeAllListeners)
        };
  }, []);


about 4 years ago · Juan Pablo Isaza 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