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

This commit is contained in:
Elian Doran 2025-09-06 16:02:25 +03:00
parent 8dcef5ea9f
commit 5a3f432d89
No known key found for this signature in database

View File

@ -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" />