A simple react countdown timer
I was recently trying to make a simple countdown timer which counts from a specific time-interval and “finishes” itself
I just found it amazing that a few lines of code could bring in such a thing!
the code just uses a state called “minutes” which gets initialized with the total number of seconds for which the timer stays.
Get Dixit Patel’s stories in your inbox
Join Medium for free to get updates from this writer.
The component accepts minutes till which it must stay alive, converts that into seconds, runs the countdown and then clears the internal logic.
<Timer classNames="time-text" minutes={Number(10)} />and here’s the entire code







