Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

167
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda