While trying to make an app that would ask for 3 dates, i've stumbled on a problem :
I have this:
onDateChange = (state) => (event, value) => {
this.setState({
[state]: name
});
}
that is called by:
<DatePicker
dateMes={this.state.dateMes}
mode="date"
placeholder="select date"
format="DD-MM-YYYY"
minDate="01-01-1950"
maxDate="01-01-2050"
androidMode="spinner"
showIcon={false}
onDateChange={this.onDateChange('dateMes')}
/>
When loaded, my 3 datepickers are juste filled with the placeholder. When i open them and select a date, nothing will change (as if i never selected a date)
I believe it's not finding how to make the onDateChange work, but I don't know how to make it work
Thanks for the help !
EDIT: Thanks to Chris G, i got a solution. My function now looks like
onDateChange = (state) => (event, name) => {
this.setState({
[state]: name
});
}
The error disappeared, but the date are not changed with the datepicker.
valuebut you're usingnamein your setState call.