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

190
Views
SetInterval after 15mins

I tried to setInterval every 15mins but it's not working

const timeInterval = 900_000
useEffect(() => {
        const refetch = setInterval(() => {
            console.log("Refetch");
            
        }, timeInterval)
        return () => clearInterval(refetch)
    })

But every 10sec, this's working. How can do that with bigger time like 30mins, 1hour?

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

const timeInterval = 15 * 60 * 1000
useEffect(() => {
        setInterval(() => {
            console.log("Refetch");
        }, timeInterval)
    }, []);
about 4 years ago · Juan Pablo Isaza Report

0

setTimeout and setInterval uses milliseconds. 1000 milliseconds is 1 second, so multiply 1000 by 60 to get 1 minute in milliseconds, and then times that by 15 to get 15 minutes in milliseconds.


const timeInterval = 1000 * 60 * 15;


about 4 years ago · Juan Pablo Isaza Report

0

You need to set your dependency list (which is nothing, []) so, it'll run once on component mount:

const timeInterval = 900_000
useEffect(() => {
        const refetch = setInterval(() => {
            console.log("Refetch");
            
        }, timeInterval)
        return () => clearInterval(refetch)
    }, [])
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!