import * as React from 'react'; import { Calendar as BigCalendar, CalendarProps, momentLocalizer, Event, } from 'react-big-calendar'; import * as moment from 'moment'; import './Calendar.css'; export interface CalendarEvent extends Event {} export interface Props extends Partial { events?: CalendarEvent[]; } export interface State { hasError: boolean; } class Calendar extends React.PureComponent { calendarLocalizer: any; constructor(props: Props) { super(props); this.state = { hasError: false, }; this.calendarLocalizer = props.localizer || momentLocalizer(moment); } static getDerivedStateFromError(error: any) { return { hasError: true }; } render() { const { style = {}, events = [], ...rest } = this.props; const { hasError } = this.state; if (hasError) { return
An unexpected error has occurred.
; } return ( ); } } export default Calendar;