Javascript react dates DayPickerAgeController,如果用户在已选中时单击它,是否有方法清除startDate或endDate?

Javascript react dates DayPickerAgeController,如果用户在已选中时单击它,是否有方法清除startDate或endDate?,javascript,reactjs,react-dates,Javascript,Reactjs,React Dates,我试图找到一种方法,让用户在点击已选日期时取消选择当前选定日期。 我正在使用dayPickerageController来自react dates库 以下是我的源代码: constructor(props) { super(props); this.state = { startDate: null, endDate: null, focusedInput: 'startDate'

我试图找到一种方法,让用户在点击已选日期时取消选择当前选定日期。 我正在使用
dayPickerageController
来自
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}
                />
        )
    } 
构造函数(道具){
超级(道具);
此.state={
startDate:null,
endDate:null,
焦点输入:“开始日期”
}
}
handleDateChange=({startDate,endDate})=>{
this.setState({startDate,endDate});
}
handleFocusChange=focusedInput=>{
this.setState({focusedInput:focusedInput | |'startDate'})
}
dayClick=日期=>{
console.log(日期)
}
render(){
返回(
)
} 

如果我清楚地理解您的问题,您必须将
minimumNights={1}
属性设置为不允许用户选择日期

<DayPickerRangeController
  onDatesChange={this.handleDateChange}
  focusedInput={this.state.focusedInput}
  onFocusChange={this.handleFocusChange}
  startDate={this.state.startDate}
  endDate={this.state.endDate}
  minimumNights={1}
 /> 

如果我清楚地理解您的问题,您必须将
minimumNights={1}
属性设置为不允许用户选择日期

<DayPickerRangeController
  onDatesChange={this.handleDateChange}
  focusedInput={this.state.focusedInput}
  onFocusChange={this.handleFocusChange}
  startDate={this.state.startDate}
  endDate={this.state.endDate}
  minimumNights={1}
 />