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

287
Vistas
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 Respuestas
Responde la pregunta

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 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