I have this factory method that creates functions for each change handler:
makeHandleChange = changedProperty => newVal => {
const newState = { ...this.state, [changedProperty]: newVal };
this.setState({ ...newState });
};
It is being executed for example like that:
onChange={this.makeHandleChange('phoneNumber')}
How can I set the state of a property object using this function?
For example I have to setState
the info.phoneNumber
property:
state = {
info: {
phoneNumber: '',
},
}
How can I do that with this makeHandleChange
function?