I’m trying to use the following component:
<Eventcalendar
clickToCreate={true}
dragToCreate={true}
dragToMove={true}
dragToResize={true}
data={events}
onEventClick={onEventClick}
onEventCreated={onEventCreated}
onEventDeleted={onEventDeleted}
onEventUpdated={onEventUpdated}
/>
which updates the dragged event through the following function:
const onEventUpdated = useCallback((args) => {
dispatch(eventStartUpdate({...args.event}));
}, [dispatch]);
the reducer handles the action of updating the event in this way:
case types.eventUpdate:
return {
...state,
events: state.events.map(
e => (e.id === action.payload.id) ? { ...action.payload } : e
)
};
Everything seems to be ok, in fact the ‘onEventDeleted’ action is handled in a similar way, but when I try to drag and drop an event I get the following error:
ERROR
A state mutation was detected between dispatches, in the path 'calendar.events.0.start'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)
I tried using Immer but I get a similar error:
ERROR Cannot assign to read only property 'start' of object '#<Object>' TypeError: Cannot assign to read only property 'start' of object '#<Object>'
Thanks to anyone who can help