I have default state like this:
this.state = {
location:{
lat: 1234,
lng: 3245
}
}
so every time I want to update either lat or lng I have to do this
this.setState({ location: {...this.state.location, lat: newLate} })
or
this.setState({ location: {...this.state.location, lng: newLng } })
if I have several setState in my component I have to write a lot of ..., worse if I have one level of nested object to work with. Also it's dangerous to do this {this.state.location.lat} because it will have error and it make the whole app to crash if location is not defined. What's the tip when you work on multiple nested array of object or object in react?
multiple nested array- but ... there is no arrayor...makes the code more compact already, how short do you want the code to be?