const map = {
dateOne: {
stateKey: 'date',
vari: date1,
handler: this.onCalendarOne,
},
dateTwo: {
stateKey: 'date2',
vari: date2,
handler: this.onCalendarTwo,
}
};
const item = map[name];
Preciso colocar a variável "vari" no onchange, como posso fazer isso?
Segue:
<InputDate className='form-control roundbridges SizeInputCalendar' id='calendarIdaVolta' name='calendarIdaVolta' onChange={dateNew => { this.setState({ ${this.state[item.vari]}: dateNew }); }} value={this.state[item.stateKey]} min={this.state.minDate} max={this.state.maxDate} />
Obrigado