React-calendar: How to disable dates before current date?

Created on 26 Aug 2020  路  3Comments  路  Source: wojtekmaj/react-calendar

hello @all
please help me to find the solution as i want to disable the dates that are before current date.

Thnaks!

question

Most helpful comment

You could use minDate and pass in todays date to disable all dates before todays date. You could also use tileDisabled.

<Calendar minDate={new Date()} />

Or

private tileDisabled = ({date }: CalendarTileProperties & {activeStartDate: Date}) =>
{
   if(date.valueOf() < todaysDate.valueOf()) {
      return true;
   }

   return false;
}

<Calendar tileDisabled={this.tileDisabled} />

All 3 comments

You could use minDate and pass in todays date to disable all dates before todays date. You could also use tileDisabled.

<Calendar minDate={new Date()} />

Or

private tileDisabled = ({date }: CalendarTileProperties & {activeStartDate: Date}) =>
{
   if(date.valueOf() < todaysDate.valueOf()) {
      return true;
   }

   return false;
}

<Calendar tileDisabled={this.tileDisabled} />

In general, minDate is the best to disable all dates before a certain date. tileDisabled is best when you want to disable select dates. So in this case, minDate is the way.

thanks @Herting @wojtekmaj

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Hubro picture Hubro  路  3Comments

wojtekmaj picture wojtekmaj  路  3Comments

andymj picture andymj  路  5Comments

dumkanki picture dumkanki  路  4Comments

amansur picture amansur  路  6Comments