acidb / mobiscroll

Cross platform UI controls for progressive web and hybrid apps (plain JS, jQuery, Angular and React)
https://mobiscroll.com
Other
1.54k stars 439 forks source link

Eventcalendar crashes when resources from Immer.js reducer #520

Closed jorgenader closed 1 year ago

jorgenader commented 1 year ago

Issue occurs when rendering calendar with resouces from Immer based reducer.

Example reducer:

import {produce} from 'immer';
const reducer = produce((state, action) => {
    switch (action.type) {
        case 'resources':
            state.resources = action.payload;
            break;
    }
});

and in the component rendering the calendar:

const [state, dispatch] = useReducer(reducer, initialState);
...

<Eventcalendar resources={state.resources} ... />

Mobiscroll version: 5.26 Immer: 9.0

dioslaska commented 1 year ago

Currently the eventcalendar does not work with immutable objects (resources, events). We're planning to make it work, until than the workaround is to pass a deep copy of the data, which is not immutable.

dioslaska commented 1 year ago

We added the immutableData option in 5.28.0, when set to true, the calendar will not modify the passed data.