How to change the values of a object in the array in the react state by using setState?
My react state:
this.state = {
serviceFees: [
{
periodFrom: new Date(),
periodTo: new Date(new Date().getTime() + 24 * 60 * 60 * 1000),
serviceFeeType: 'percentage',
serviceFee: '',
refundableStatus: 'refundable'
}
]
};
And some of my onChange fuctions:
handlePeriodFromDateChange = (date) => {
this.setState({
periodFrom: date,
periodTo: new Date(date.getTime() + 24 * 60 * 60 * 1000)
});
}
handleRefundableStatus = (e) => {
this.setState({
refundableStatus: e.target.value
})
}
handleChange = (e) => {
this.setState({
[e.target.name]: e.target.value
})
}