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

160
Views
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
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!