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

236
Vistas
clearInterval() on navigation.push react

I wrote some code to set an Interval on my dealScreen:

let timer;
  useEffect(() => {
        timer = setInterval(() => { 
          console.log('test');
        }, 1000);
    return () => clearInterval(timer);
  }, []);

When navigating to another page with navigation.push the Interval isn't cleared. How can I force the interval to be cleared on navigation. Because it is a stack so I think the page is still behind the new page.

When using navigation.replace it works but then I have no correct history back.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try to call the clearInterval(timer) function when you trying to navigate.

Example:

  let timer;
  useEffect(() => {
    timer = setInterval(() => {
      console.log('test');
    }, 1000);
  }, []);

  const navigateToNextScreen = () => {
    clearInterval(timer);
    navigation.push('Next Sreen');
  };

I hope this help you out. Thanks.

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