I have the following and I am learning TypeScript on the go,
interface Props {
contentHeight: number,
dayRender(
date: Date,
el: HTMLElement,
view: object
): void,
...
dayRender is a custom function of the plugin I am using: https://fullcalendar.io/docs/dayRender
and a component like so:
export class CalendarComponent extends Component<Props> {
...
disableSaturday = ( slots: Array<{date: Date}> ) => {
for(let i = 0; i < slots.length; i += 1) {
if (getDay(slots[i].date) === Day.Sunday) {
console.log(`it's saturday`)
}
}
}
render() {
const {
contentHeight,
dateClick,
defaultView,
displayEventTime,
header,
selectedAvailablity: { endDate, slots, startDate },
selectedDate
} = this.props
this.goToDate(selectedDate)
return (
<Fragment>
<FullCalendar
contentHeight={contentHeight}
// dayRender={'sth on day render'}
dateClick={dateClick}
defaultView={defaultView}
displayEventTime={displayEventTime}
events={slots}
dayRender={this.disableSaturday}
firstDay={Day.Monday}
header={header}
now={selectedDate}
plugins={[dayGridPlugin, interactionPlugin]}
ref={this.calendarRef}
validRange={{
start: startDate,
end: endDate,
}}
/>
</Fragment>
...
I have updated the Props interfact and updated the type of dayRender but and I am getting a type error:
