我正在尝试找到一种方法让用户在单击已选择的日期时取消选择当前选定的日期。我正在DayPickerRangeController
从react-dates
图书馆使用。
这是我的源代码:
constructor(props) {
super(props);
this.state = {
startDate: null,
endDate: null,
focusedInput: 'startDate'
}
}
handleDateChange = ({ startDate, endDate }) => {
this.setState({ startDate, endDate });
}
handleFocusChange = focusedInput => {
this.setState({ focusedInput: focusedInput || 'startDate' })
}
dayClick = date => {
console.log(date)
}
render() {
return (
<DayPickerRangeController
onDatesChange={this.handleDateChange}
focusedInput={this.state.focusedInput}
onFocusChange={this.handleFocusChange}
startDate={this.state.startDate}
endDate={this.state.endDate}
/>
)
}