From 1256dc4a21c10e6ce8a8da696585b52b362593dd Mon Sep 17 00:00:00 2001 From: mertsincan Date: Fri, 19 Mar 2021 10:59:03 +0300 Subject: [PATCH] Refactor #1884 - For FullCalendar --- src/components/fullcalendar/FullCalendar.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/components/fullcalendar/FullCalendar.js b/src/components/fullcalendar/FullCalendar.js index 515ff58cf3..3336ff1e50 100644 --- a/src/components/fullcalendar/FullCalendar.js +++ b/src/components/fullcalendar/FullCalendar.js @@ -1,7 +1,6 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import ObjectUtils from '../utils/ObjectUtils'; -import {Calendar} from '@fullcalendar/core'; export class FullCalendar extends Component { @@ -55,13 +54,17 @@ export class FullCalendar extends Component { } } - initialize() { - this.calendar = new Calendar(this.element, this.config); - this.calendar.render(); + async initialize() { + const fullCalendarModule = await import('@fullcalendar/core'); - if (this.props.events) { - this.calendar.removeAllEventSources(); - this.calendar.addEventSource(this.props.events); + if (fullCalendarModule && fullCalendarModule.Calendar) { + this.calendar = new fullCalendarModule.Calendar(this.element, this.config); + this.calendar.render(); + + if (this.props.events) { + this.calendar.removeAllEventSources(); + this.calendar.addEventSource(this.props.events); + } } } @@ -76,4 +79,4 @@ export class FullCalendar extends Component {
this.element = el} style={this.props.style} className={this.props.className}>
); } -} \ No newline at end of file +}