for complex data types, such as arrays or objects,
can be used in Vue:
data() {
return {
obj: dataObject
}
}
method: {
modify: function(newObj) {
this.obj = newObj
}
}
but react should use:
this.setState({
obj: Object.asign({}, oldObj, newObj)
})
Vue can modify the reference of an object directly, but react cannot be modified directly. Instead, it needs to use Object.asign. What is the underlying reason? Why is that?