Create a timer that can be started and stopped
Create a 5 minute countdown timer that can be started and stopped.
- When the page is first loaded, the counter displays 5 minutes (i.e.
5:00
) - When the user clicks "Start", the counter starts counting down.
- When the user clicks "Stop", the timer should start elapsing time.
- When the user clicks "Reset", the timer should be reset to 5 minutes again
Use React with Typescript to build you solution.
You can fork this repo to try out your solution.
What you will practice:
- working with
Date
objects - formatting dates
useState
hook- using
setInterval
in React - using the "updater" version of
useState
setter function
Solution
Once you tried the exercise yourself, check out the official solution to compare your work!
Member discussion