I was reading the react documentation State Updates are Merged and theres a part it says when we set a object like this eg: this.setState({comments}) it completely replaces this.state.comments.
So, I wonder if the approach to change name of user object on event onChangeText is valid, because the whole object it'll be replaced everytime onChangeText is called.
Is that a good practice or have side effects like bad perfomance?
example code:
this.state = {
user:{
name: "",
surname: "",
},
isLoading: false
};
/***/
onChangeText={name => this.setState({
user: {
...user,
name
}
})}