"Maximum recursive updates exceeded." with Vue.js and FullCalendar

Viewed 24

I have a Laravel 9 and Vue.js 3 project where I use the FullCalendar package. All events that come in the calendar are retrieved from the database via Laravel.

Calendar.vue:

<template>
    <div class="demo-app">
        <div class="demo-app-main">
            <FullCalendar
                ref="schedule"
                :options='calendarOptions'
            >
                <template v-slot:eventContent="arg">
                    <b>{{ arg.timeText }}</b><br/>
                </template>
            </FullCalendar>
        </div>
    </div>
</template>

<script>
import '@fullcalendar/core/vdom' // solves problem with Vite
import FullCalendar from '@fullcalendar/vue3';
import timeGridPlugin from '@fullcalendar/timegrid';
import nlLocal from '@fullcalendar/core/locales/nl';
import bootstrap5Plugin from '@fullcalendar/bootstrap5';

export default {
    components: {
        FullCalendar
    },
    data: function () {
        return {
            calendarOptions: {
                locale: nlLocal,
                plugins: [
                    timeGridPlugin,
                    bootstrap5Plugin
                ],
                themeSystem: 'bootstrap5',
                headerToolbar: null,
                dayHeaderFormat: {
                    weekday: 'short',
                    month: 'long',
                    day: 'numeric',
                    omitCommas: true
                },
                slotLabelFormat: {
                    hour: '2-digit',
                    minute: '2-digit',
                    omitZeroMinute: false,
                    meridiem: 'short'
                },
                titleFormat: {
                    year: 'numeric', month: 'long', day: 'numeric'
                },
                nowIndicator: true,
                initialView: 'timeGridWeek',
                events: this.getEvents,
                editable: false,
                selectable: false,
                selectMirror: true,
                dayMaxEvents: true,
                weekends: false,
                eventClick: this.openLessonModal,
                slotDuration: '00:15:00',
                eventColor: '#4782f6'
            },
        }
    },
    methods: {
        getEvents(info, successCallback, failureCallback) {
            axios.get(this.route('student.schedules.get-lessons'), {
                params: {
                    start: this.$dayjs(info.start).format('YYYY-MM-DD'),
                    end: this.$dayjs(info.end).format('YYYY-MM-DD'),
                    class: this.params.class,
                    teacher: this.params.teacher
                }
            })
                .then((response) => {
                    successCallback(response.data);
                })

            // EXAMPLE RESPONSE FROM THE DATABASE:
            // successCallback([
            //     {
            //         "id": 1,
            //         "subject_id": 3,
            //         "teacher_id": 1,
            //         "classroom_id": 1,
            //         "start": "2022-09-08 15:00:00",
            //         "end": "2022-09-08 15:55:00",
            //         "subject": {
            //             "id": 3,
            //             "name": "Engels"
            //         },
            //         "teacher": {
            //             "id": 1,
            //             "abbreviation": "TEA"
            //         },
            //         "classroom": {
            //             "id": 1,
            //             "name": "S101"
            //         }
            //     },
            //     {
            //         "id": 3,
            //         "subject_id": 2,
            //         "teacher_id": 1,
            //         "classroom_id": 1,
            //         "start": "2022-09-08 09:00:00",
            //         "end": "2022-09-08 09:55:00",
            //         "subject": {
            //             "id": 2,
            //             "name": "Nederlands"
            //         },
            //         "teacher": {
            //             "id": 1,
            //             "abbreviation": "TEA"
            //         },
            //         "classroom": {
            //             "id": 1,
            //             "name": "S101"
            //         }
            //     },
            // ])
        },

The problem is that every time the events are retrieved from the database the console gives the following error:

[Vue warn]: Maximum recursive updates exceeded. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.

enter image description here

When I build the code for production (npm run build), and I view the page, the page freezes completely. I also found on the internet that it may have to do with an infinity loop. But couldn't find a solution to the problem.

Does anyone know where the problem comes from?

0 Answers
Related