2

I am trying to make it so that in react-day-picker, only the dates that are available are selectable (i.e. A user is only available for two days, all those other days are disabled and unselectable). I've tried doing this method:

    <DayPicker
      selectedDays={this.state.selectedDays}
      onDayClick={this.handleDayClick}
      disabledDays={(day => (day !== ServiceRequestEngagementCreateModal.availableDates(service.available_dates)))}
    />

But that makes all of the dates unavailable.

Any help would be appreciated, thanks!

Alex Masson
  • 31
  • 1
  • 4

1 Answers1

1

I figured it out. Heres the code we ended up using

render() {
const availableDateStrings = service.available_dates.map(date => new Date(date.split('-').join(',')).toDateString())
return(
...
<DayPicker
              selectedDays={this.state.selectedDays}
              onDayClick={this.handleDayClick}
              disabledDays={(day => (availableDateStrings.indexOf(day.toDateString()) === -1))}
            />
...
)}
Alex Masson
  • 31
  • 1
  • 4