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

166
Vistas
React JS Hooks: button for display data

so im trying to have a button where the user by pressing it, will display on the screen some fetched data from an API. so far so good i fetched the data and when press the button it prints the result. but i want to create one more button, where if the user press, it will print a random json data from the API every 3 seconds(like random quotes), right now i just have it just by pressing once and get one random solid displaying. is there a way with hooks on how to do it? Edit: the problem that i encounter is that it prints no matter what the user press, if he press to get one joke it always changes, and i dont want that.

first button that i have

<button id="button" onClick = {getQuote}>Get one quote</button> <h3 dangerouslySetInnerHTML = {{__html: quote}} />

and the second button/toggle(for start stop) bellow for getting/appearing a random joke every 3 seconds on screen

<button id="button" onClick = {handleGetT}>{isActive ? 'Get quotes' : 'Stop'}</button> <h3>{isActive ? null : quote}</h3>
about 4 years ago · Juan Pablo Isaza
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