-1

How can I block dates in react-dates airbnb with moment date range?

const BAD_DATES = [
   moment.range('2018-04-15', 'YYYY-MM-DD', '2018-04-27', 'YYYY-MM-DD'),
   moment.range('2018-05-10', 'YYYY-MM-DD', '2018-05-20', 'YYYY-MM-DD'),
];
const isDayBlocked = day => BAD_DATES.filter(d => d.isSame(day, 'day')).length > 0;
return (
  <DateRangePicker
    isDayBlocked={isDayBlocked}
    ...
  />
);
TylerH
  • 20,799
  • 66
  • 75
  • 101

1 Answers1

0

I have not used this component but I think you should like this.

if it passing the selected day to the function -> You should use range.contains(day) in the filter

OR

if you passing the selected date range to the function -> you should use range1.overlaps(range2) in the filter

Lakshitha Ruwan
  • 949
  • 1
  • 9
  • 12