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

248
Visualizações
subscription returned by AppState.addEventListener() is void

when i try to remove the eventListener like in the React native documentation for AppState: https://reactnative.dev/docs/appstate, I either get an error that there is no such function remove() on undefined since AppState.addEventListener() returns void or the eventListener is just not removed.

here is my code:

useEffect(() => {
    const subscription = AppState.addEventListener('change', (nextAppState: any) => {
      // some stuff 
    });

    return () => {
      subscription.remove();
    };
  }, []);

If anyone has an idea on that matter, i would be very grateful, thank you !

I found someone on github with the same issue I believe: https://github.com/facebook/react-native/issues/33151

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

0

ok, found the answer this due to the fact that im on react-native 0.64 and not 0.67

about 4 years ago · Juan Pablo Isaza Relatório

0

This happens if you're using a version of react-native prior to 0.65. Starting with 0.65, AppState.removeEventListener is deprecated in favor of using remove in the subscription returned by `addEventListener.

These are the 0.64 docs for removeEventListener. And these are the corresponding 0.65 docs that add the deprecation notice.

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