Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Interact and Update State in React with useState


    In this lesson, we'll create a Stopwatch component that will store the current time in its state. We will then have the DOM display the current time as the state is updated.

    We'll cover:

    • React's useState hook
    • Setting a reference to an interval using React's useRef
    • Creating a handleRunClick function that handles flipping the running state plus creating and clearing an interval
    • Using the useEffect hook to clear the interval when the component unmounts