Are there any use-cases where a nested object as state is either more optimal/easier to work with than individual properties?
For instance if I wanted to express some user controls for interacting with a photo in state I could write something like so (nested object):
this.state = {
photoControls: {
open: false,
id: null,
thumbnailUrl: null
}
}
Or I could also write it this way (individual properties):
this.state = {
photoControlsOpen: false,
photoControlsId: null,
photoControlsThumbnailUrl: null
}
Although I can logically group properties together using a nested-object style of state, it seems to only prove more verbose when trying to update just one, or a couple, of those properties.
This being said, what are the benefits (if any) to using nested objects in state as opposed to using individual properties. I understand that nested-objects might feel more proper, but I can't think of any benefits to them, anyone have any insight?