I have a Ant Design Calendar component in my React project -
<Calendar
value={this.state.value}
fullscreen={false}
onPanelChange={this._onPanelChange}
onSelect={this._onSelect}
disabledDate={(current) => {
return current && moment().isAfter(current, "day");
}}
/>
and I have the following state -
this.state = {
value: moment(),
scheduleDate: moment(),
}
the _onSelect
function looks like -
_onSelect = (value) => {
this.setState({
value,
scheduleDate: value,
});
this.props.setScheduleDate(this.state.scheduleDate.toDate());
console.log(this.state.scheduleDate);
};
When the user selects a date (say, 23rd of April, 2021), the console.log
gives me a date of 22nd April(current default date), 2021. Similarly, when the user selects 24th April, 2021, the console.log
gives 23rd April, 2021.
It always sets scheduleDate
to what was selected in the previous step. Any idea what's wrong and how can I fix it? Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire