There is a classic handle Change function. I can change the data in the same directory. There is no problem. but I have sub-data. I can't change them. I want to handle this as clean without typing the extra functions in handlechange. How can I do it?
My state:
this.state = {
formData: {
appointedBroker: '',
propertyInformations: {
rent: false,
property: {
housing: false,
},
features: {
rooms: ""
},
location: ""
},
}
}
my handleChange Function:
handleChange(event) {
const { formData } = this.state;
formData[event.target.name] = event.target.value;
this.setState({ formData });
}
and my inputs
<TextField
value={propertyInformations.features.rooms}
onChange={(e) => this.handleChange(e)}
id="rooms"
name={'rooms'}
type={'text'}
label={t('Rooms')} />
in this case, I just changed "appointedBroker" data For example; I want to change "rooms"