Vigyata.AI
Is this your channel?

React 19 Tutorial - 21 - State as a Snapshot

6.0K views· 202 likes· 5:47· Nov 25, 2025

🛍️ 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 State as a Snapshot in React 19

About This Video

In this lesson, I explain one of the most confusing “wait, what?” moments in React: why logging state before and after calling setState shows the same value, even though the UI updates. If you’ve ever seen `count` log as 0 before `setCount`, and still 0 after `setCount`, but the screen shows 1, this video is for you. The reason comes down to the three phases we discussed earlier: trigger, render, and commit. When you call `setCount`, React enters the trigger phase and simply schedules a re-render—it does not pause your event handler, re-render, and then resume your function. That never happens. I show this clearly with logs: during the entire event handler, you’re working with a snapshot of state from the current render. That snapshot is frozen, like a photo—inside that render, state values won’t change. This becomes really important when you fire multiple updates in a row like `setCount(count + 1)`, `setCount(count + 5)`, `setCount(count + 10)`: they all read the same snapshot value, queue updates, and the last one wins. Even an async callback like `setTimeout` still “sees” the old snapshot. It might feel weird at first, but it’s exactly what makes React predictable.

Frequently Asked Questions

🎬 More from Codevolution