Object as Initial Values

In this lesson, we'll discuss the difference between setState and useState.

Is it possible to use an object with useState as opposed to multiple useState calls?

Absolutely!

If you choose to do this, you should note that unlike setState calls, the values passed into useState replace the state value.

setState merges object properties but useState replaces the entire value.

Get hands-on with 1000+ tech skills courses.