Vigyata.AI
Is this your channel?

React 19 Tutorial - 37 - Refs and useRef Hook

3.2K views· 109 likes· 7:23· Jan 15, 2026

🛍️ Products Mentioned (2)

Github - https://github.com/gopinav/React-19-Tutorials Become a Fullstack Developer with Scrimba - https://scrimba.com/fullstack-path-c0fullstack?via=Codevolution Follow me + Twitter - https://twitter.com/CodevolutionWeb Business - codevolution.business@gmail.com Refs and useRef Hook in React 19

About This Video

Up until now in this React 19 series, I’ve been using state for anything that changes over time—and that’s still the right default. State exists for two reasons: it persists values across renders, and it updates the UI when those values change. But sometimes you need to remember something across renders that has absolutely no impact on what you render. In this lesson, I introduce refs and the useRef hook with a simple, practical example: building a stopwatch. We track elapsed time in state because the UI depends on it, and I wire up the Start button using setInterval to increment time every second. The tricky part is stopping the timer. The interval ID returned by setInterval needs to persist so we can call clearInterval later, but storing it in a regular variable fails across re-renders, and storing it in state is unnecessary because the UI doesn’t care about the interval ID. That’s where useRef fits perfectly: it gives me a ref object with a current property that persists for the lifetime of the component and doesn’t trigger re-renders when it changes. The takeaway is simple: state is for rendering, refs are for remembering.

Frequently Asked Questions

🎬 More from Codevolution