name: '',
title: '',
fr: {
name: '',
title: ''
},
en: {
name: '',
title: ''
}
}
onChange = ({ target: { value, dataset: { objName, key } } }) => {
this.setState(({ [objName]: obj }) => ({
[objName]: {
...obj,
[key]: value,
},
}));
}
<input data-obj-name="fr" data-key="name" value={this.state.fr.name} onChange={this.onChange} />
<input data-obj-name="en" data-key="title" value={this.state.en.title} onChange={this.onChange} />