useEffect(() => {
if (pickedService.length > 0 && gender !== "") {
pickedService.forEach((service) => {
let event = calendarRef.current!.control.events.find(
service.extra.appointment_id ?? service.service.id_service
);
if (service.extra.toDelete === false) {
if (event !== null) {
let clientName = setIsEditingEventPosition(true);
calendarRef.current!.control.events.update({
id: service.extra.appointment_id ?? service.service.id_service,
text: service.service.id_service,
start: service.date!["start"],
end: service.date!["end"],
resource: service.resource.id,
cssClass: service.extra.appointment_id
? "draft_selected_event"
: "draft_event",
barHidden: true,
tag: {
marker: service.service.ec_color_light,
client:
(!name ? "Passaggio" : name) +
" " +
(surname ??
(surname ||
(watchFields.id_cus === undefined
? gender
: extractGenderFromID(watchFields.id_cus!)))),
service: service.service.name,
writtenNote: note,
note:
service.extra.note !== undefined && service.extra.note !== "",
heart: service.extra.worker_lock !== "0",
clock: service.extra.time_lock !== "0",
},
});
} else {
setIsEditingEventPosition(true);
const event = new DayPilot.Event({
id: service.extra.appointment_id ?? service.service.id_service,
text: service.service.id_service,
start: service.date!["start"],
end: service.date!["end"],
resource: service.resource.id,
barHidden: true,
cssClass: service.extra.appointment_id
? "draft_selected_event"
: "draft_event",
tag: {
marker: service.service.ec_color_light,
service: service.service.name,
client:
(!name ? "Passaggio" : name) +
" " +
(surname ??
(surname ||
(watchFields.id_cus === undefined
? gender
: extractGenderFromID(watchFields.id_cus!)))),
writtenNote: service.extra.note,
note:
service.extra.note !== undefined && service.extra.note !== "",
heart: service.extra.worker_lock !== "0",
clock: service.extra.time_lock !== "0",
},
});
calendarRef.current?.control.events.add(event);
}
}
});
} else {
}
}, [pickedService, gender, deferredQueryName, deferredQuerySurname]);
When i run this code, everytime the useffect is performed the whole calendar events flickers, not just those whom i'm dealing with. Why?