Vigyata.AI
Is this your channel?

React 19 Tutorial - 24 - useState with Objects

5.2K views· 181 likes· 9:28· Dec 1, 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 useState with Objects

About This Video

Up until now in this React 19 series, we’ve been using simple state values like numbers, strings, and booleans. In this video, I switch to what you’ll actually do in real-world apps: storing structured data in state using objects. I build a fresh `UserProfile` component and keep a user’s name, age, and email inside a single `user` object with `useState`, then render those values with simple dot notation. From there, I show the most common beginner mistake: calling `setUser({ name: 'Clark Kent' })` and accidentally wiping out the rest of the object. The key takeaway is that `setState` replaces the entire object, so you need to spread the existing object first and then override just the property you want: `{ ...user, name: 'Clark Kent' }`. I repeat the same pattern to update age, update multiple properties at once, and then take it one step further with a nested `address` object. That’s where you learn the next important detail: spreading the outer object isn’t enough for nested updates—you also need to spread the nested object (`{ ...user, address: { ...user.address, city: 'Metropolis' } }`).

Frequently Asked Questions

🎬 More from Codevolution