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

$99.00
Complete Package
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 in...

This lesson is part of the full version of the React Bootcamp. Already joined? Log in here

Transcript

In this app, we want to make a very basic stopwatch, we want to count up in seconds when we click on start.

And we also want to be able to stop this timer. The trick to implementing this is realizing that we have a set interval function set interval takes a callback, this enables us to count up, t...