Skip to content

Build your personal knowledge base with Trilium Notes

feat(react/collections/calendar): improve performance on option change

Elian Doran5a3f432d89d1
diff --git a/apps/client/src/widgets/collections/calendar/calendar.tsx b/apps/client/src/widgets/collections/calendar/calendar.tsx
index bd1b5d1262..92968bbb27 100644
--- a/apps/client/src/widgets/collections/calendar/calendar.tsx
+++ b/apps/client/src/widgets/collections/calendar/calendar.tsx
@@ -1,4 +1,4 @@
-import { useLayoutEffect, useRef } from "preact/hooks";
+import { useEffect, useLayoutEffect, useRef } from "preact/hooks";
import { CalendarOptions, Calendar as FullCalendar, PluginDef } from "@fullcalendar/core";
import { RefObject } from "preact";
@@ -20,7 +20,11 @@ export default function Calendar({ calendarRef, ...options }: CalendarProps) {
}
return () => calendar.destroy();
- }, [ containerRef, options ]);
+ }, [ ]);
+
+ useEffect(() => {
+ calendarRef?.current?.resetOptions(options);
+ }, [ options ]);
return (
<div ref={containerRef} className="calendar-container" />