0

How can I disable click on dates in "Selecting multiple dates".

Inside my render,

<DayPicker selectedDays={this.state.selectedDays} onDayClick={this.handleMultiDayClick} disabledDays={{ before: this.state.currentDay }} />

I am able to disable days but if I click on disabled dates then they are also added in the state.

I would appreciate the help.

TEMP
  • 235
  • 2
  • 7
  • 17

1 Answers1

2

Can you not simply check for disabled dates in your onclick handler and exclude the disabled dates from your selectedDays state object?

handleMultiDayClick(e) {
  // check here for disabled dates
  if(!disabledDate) {
    this.setState({selectedDays: this.state.selectedDays.push(newDate).slice(0)})
  }
}
jsdeveloper
  • 3,945
  • 1
  • 15
  • 14