Advanced React

Join the React Bootcamp

The React Bootcamp is 5 full weeks of professional React training to take you from wherever you are to top-tier React programmer in record time.

Lifetime Access

$79
Complete Package
Become a React Pro
Problem

Reference Values

Use a ref to store a reference to a value, namely the setInterval id.

Using this ref, make it possible to start and stop the timer.

To start the timer, you want to count up in seconds (using state).

To stop the timer, you will need to clear the timer using clearInterval and the id stored...

This lesson is part of the full version of the React Bootcamp.

Click here to purchase.
Already joined? Log in here

Transcript

In this app, we aim to create a very basic stopwatch that counts up in seconds when the "start" button is clicked. Additionally, we want the ability to stop the timer. The key to implementing this feature is to utilize the setInterval function, which takes a callback, enabling us to increment the...