Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

233
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!