Here is my code, and it crashed.
import {
AgendaView,
DayView,
MonthView,
Scheduler,
TimelineView,
WeekView,
} from '@progress/kendo-react-scheduler';
import * as React from 'react';
import { useState } from 'react';
import { useQuery } from 'react-query';
import { useAppContext } from '../../AppContext';
import { getCalendarEvents } from './getCalendarEvents';
const workDayStart = '09:00';
const workDayEnd = '18:00';
export function Calendar() {
const { accessToken } = useAppContext();
const [isMonthView, setIsMonthView] = useState(false);
const [selectedDate, setSelectedDate] = useState(new Date());
const { data: events } = useQuery({
queryKey: ['getCalendarEvents', { selectedDate, isMonthView, accessToken }],
queryFn: getCalendarEvents,
initialData: [],
refetchOnWindowFocus: false,
});
const onDateChange = (e) => {
setSelectedDate(e.value);
console.log(e.value);
};
const onViewChange = (e) => {
if (e.value === 'month') {
setIsMonthView(true);
} else {
setIsMonthView(false);
}
};
return (
<Scheduler data={events} onDateChange={onDateChange} onViewChange={onViewChange}>
<WeekView title='Week' workDayStart={workDayStart} workDayEnd={workDayEnd} />
<AgendaView />
<DayView workDayStart={workDayStart} workDayEnd={workDayEnd} />
<TimelineView workDayStart={workDayStart} workDayEnd={workDayEnd} />
<MonthView />
</Scheduler>
);
}