state reducer change part os object code example
Example: updating nested attributes js
onChange(e) {
const { user } = { ...this.state };
const currentState = user;
const { name, value } = e.target;
currentState[name] = value;
this.setState({ user: currentState });
}