Design comparison
Solution retrospective
Made this API call and display with API. I used the setInterval function so that new data is called and displayed. An issue I am having is that if a leave the page and return, the API call does not obey the set Interval. Please let me know how I can fix this issue. I also used the useEffect function to make the API call on the initial load. Please let me know how I can improve this component and make it more efficient.
Community feedback
- @md5daltonPosted about 1 year ago
Hi thereπ
The idea is to generate a new piece of advice by clicking the dice icon so you don't need to use a timer. So you just attach a click listener on the dice icon like so:
<div className='quote-dice' onClick={() => getAdvice()}>...</div>
You can even go further by handling loading and error states. π
Marked as helpful1
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord