1 min read

Create a timer that can be started and stopped

Create a timer that can be started and stopped

Create a 5 minute countdown timer that can be started and stopped.

  1. When the page is first loaded, the counter displays 5 minutes (i.e. 5:00)
  2. When the user clicks "Start", the counter starts counting down.
  3. When the user clicks "Stop", the timer should stop elapsing time.
  4. When the user clicks "Reset", the timer should be reset to 5 minutes again

To get started, you can just spin off a new project using Vite.

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!

Show me the solution

Get the React Practice Calendar!

28 days of focused practice of increasing difficulty, going through everything from Fundamentals, Data fetching, Forms and using Intervals in React.

You will also get notified whenever a new challenge is published.