React-calendar: How can I select multiple disabled tiles?

Created on 29 May 2018  路  2Comments  路  Source: wojtekmaj/react-calendar

Hi again :-)

Thanks for a new version of react-calendar. My question is pretty straightforward I guess.
I need to disable many dates. How can I do that.

Till now I used:

                tileDisabled={({date, view }) => 
               date.getDate()===15 && date.getMonth()===4 && date.getFullYear()===2017}

Thank you for the wonderful work and great support!

question

Most helpful comment

It works with a minor changes ;-) THANK YOU!

                tileDisabled={({date, view}) =>
                    (view === 'month') && // Block day tiles only
                    disabledDates.some(disabledDate =>
                      date.getFullYear() === disabledDate.getFullYear() &&
                      date.getMonth() === disabledDate.getMonth() &&
                      date.getDate() === disabledDate.getDate()
                    )}

All 2 comments

I'd do this this way:

const disabledDates = [
  new Date(2018, 0, 1),
  new Date(2018, 1, 2),
];

(...)

tileDisabled={(date, view) ->
  (view === 'month') && // Block day tiles only
  disabledDates.some(disabledDate =>
    date.getFullYear() === disabledDate.getFullYear() &&
    date.getMonth() === disabledDate.getMonth() &&
    date.getDate() === disabledDate.getDate()
}

It works with a minor changes ;-) THANK YOU!

                tileDisabled={({date, view}) =>
                    (view === 'month') && // Block day tiles only
                    disabledDates.some(disabledDate =>
                      date.getFullYear() === disabledDate.getFullYear() &&
                      date.getMonth() === disabledDate.getMonth() &&
                      date.getDate() === disabledDate.getDate()
                    )}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

fasmart4 picture fasmart4  路  6Comments

amansur picture amansur  路  6Comments

tranvula picture tranvula  路  4Comments

andymj picture andymj  路  5Comments

wojtekmaj picture wojtekmaj  路  5Comments