1

I'm using Airbnb's react-dates (SingleDatePicker) but I can't figure out how to disable today's date. Everything else is working great, I just don't want them to be able to select today.

TylerH
  • 20,799
  • 66
  • 75
  • 101
Bob Lorriman
  • 359
  • 1
  • 3
  • 10

1 Answers1

1

isOutsideRange expects a callback that receives as an argument a day of the calendar.

You should write a function to compare this argument with the day you want to block. Example of a function

function blocksDay(day) {
  return day.isSame(moment(), ‘“day”);
}
....
<SingleDatePicker
...
isOutsideRange={blocksDay}
/>

blocksDay function executes for each day of the calendar, to know which days to allow.

You can block entire ranges, or just specific dates. This is thanks to moment.js library. Here’s a link for the docs of moment: moment

You can test moment functions in browser if you want, just open the console of the browser when you’re at moment’s website

victor.ja
  • 811
  • 1
  • 7
  • 27