Skip to content

Commit

Permalink
Refactor #1884 - For FullCalendar
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Mar 19, 2021
1 parent a2f28c0 commit 1256dc4
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/components/fullcalendar/FullCalendar.js
Original file line number Diff line number Diff line change
@@ -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 {

Expand Down Expand Up @@ -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);
}
}
}

Expand All @@ -76,4 +79,4 @@ export class FullCalendar extends Component {
<div id={this.props.id} ref={(el) => this.element = el} style={this.props.style} className={this.props.className}></div>
);
}
}
}

0 comments on commit 1256dc4

Please sign in to comment.