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

285
Views
I want to refresh the api section every 10 secondes with React

I want to repeat this action and re-render it every 10 secondes. Can someone help me with that ?

   useEffect(() => {
  const fetchData = async () => {
    setIsLoading(true)
    const response = await coinGecko.get("/coins/markets", {
      params: {
        vs_currency: "usd",
        ids: watchList.join(","),
      }
    })
    setCoins(response.data)
    setIsLoading(false)
  }

  fetchData()
},[])
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

define a state: const [repeater,setRepeater]=useState(0) in your useEffect pass it as second argument so whenever it is changed, your useEffect would run again. Now let's take care of the 10 second intervals with this piece of code: setTimeout(() => setRepeater(prevState=>prevState+1), 100000); and finally implement it like tis:

   useEffect(() => {
  const fetchData = async () => {
    setIsLoading(true)
    const response = await coinGecko.get("/coins/markets", {
      params: {
        vs_currency: "usd",
        ids: watchList.join(","),
      }
    })
    setCoins(response.data)
    setIsLoading(false)
  }

  fetchData()
  setTimeout(() => setRepeater(prevState=>prevState+1), 100000);
},[repeater])
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!