For one of my current projects, I created a timer until the release on New Year's Eve - December 31, 2022. Since the project is written in React, I...
For further actions, you may consider blocking this person and/or reporting abuse
Nice beginner article @yuridevat and great comment @lukeshiru . I also would rather store the unix timespan than the values individually, it makes easier to do math with it and you wouldn't need even to
setTimea new timespan every second, a simple subtraction would do the trick. =DBuilding on that, here's a handy hook:
Then its simple to use:
Yes good point! But as far I remember it deviates very irregularly in the milliseconds, so I tend to ignore it unless it's crucial π . But thanks for the video link, I'll watch it to refresh my memory on the subject π.
In that case only one
useEffectis needed:Wow! Thank you for your suggestion! Since my tutorial is a beginner tutorial, I won't change it, but will include your comment in the article, because it could be very important for those who want to write the code in a professional way and this comment must not be overlooked in any case!
I myself will study your solution to fully understand it. It's time for me to finally write code in a professional way! You really made my day, thanks again!
Thank you so much for your suggestions, I will insert most of your suggestions (the ones I get π ) right away!
Doh', I thought that I did not fully understand setInterval/clearInterval and useEffect. I will read about it again and update the information.
Thank you for helping me making this tutorial better, I really appreciate it.
For the HTML, you could put a Β« timer Β» role and an attribute tabindex="0" on the container of the timer.
Shame on me. Thank you very much for this advice, Francois. I should indeed include accessible code in my (future) tutorials from the beginning, and not only for my accessibility articles themselves. I will do my research and implement it. I will keep you posted when I have revised the code.
Thank you for supporting me in getting better at accessibility every day.
The explanation is beginner friendly. Kudos
Thanks, Samuel.
Hi, you're missing a closing quote everywhere you mention
<div className="timer>:)Copy paste π. Very attentive, thank you!
Hey Kaio! Could you please remove the link in your comment since this is not the right place to post it, thanks!
Nice peace. Many thanks.