From 58a857f9857e0b3dc0ef98f0f28d1928fd18bcdc Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Thu, 30 Jul 2026 14:23:26 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9A=A1=20Bolt:=20Memoize=20calendar=20gr?= =?UTF-8?q?id=20generation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .jules/bolt.md | 4 +++ .../components/calendar/CalendarMonthView.tsx | 34 ++++++++++++------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/.jules/bolt.md b/.jules/bolt.md index 231af188b..ed489c9e6 100644 --- a/.jules/bolt.md +++ b/.jules/bolt.md @@ -10,3 +10,7 @@ ## 2024-05-24 - Memoizing inline array maps **Learning:** Inline mapping of arrays inside JSX in large React components causes O(N) recalculation on every render. **Action:** Wrap inline JSX elements that map over arrays (e.g., lists of tasks) in a `useMemo` hook with specific dependencies. + +## 2024-05-24 - Memoizing calendar grid generation +**Learning:** Inline array generation and mapping within JSX (e.g., `Array.from({ length: 35 }).map(...)`) causes O(N) re-renders and blocks the main thread during unrelated state updates, especially for grid components like calendars. +**Action:** Wrap inline array generation and mapping inside JSX in a `useMemo` hook to avoid unnecessary re-renders. diff --git a/frontend/src/components/calendar/CalendarMonthView.tsx b/frontend/src/components/calendar/CalendarMonthView.tsx index ae8b731d6..e40b6c00c 100644 --- a/frontend/src/components/calendar/CalendarMonthView.tsx +++ b/frontend/src/components/calendar/CalendarMonthView.tsx @@ -20,6 +20,26 @@ export function CalendarMonthView({ visibleMonthEvents }: Props) { return grouped; }, [visibleMonthEvents]); + // ⚡ Bolt Performance Optimization: + // Wrapped the inline array mapping of 35 grid cells inside a `useMemo` hook. + // Impact: Eliminates O(N) element creation (35 iterations) and prevents blocking + // the main thread during unrelated state updates, significantly reducing render time. + const gridCells = useMemo(() => { + return Array.from({ length: 35 }).map((_, i) => { + const dayEvents = monthEventsByDay.get(i) ?? []; + return ( +
+ {i < 31 ? i + 1 : ''} + {dayEvents.map((event) => ( +
+ {event.time} {event.title} +
+ ))} +
+ ); + }); + }, [monthEventsByDay]); + return (
@@ -27,19 +47,7 @@ export function CalendarMonthView({ visibleMonthEvents }: Props) {
{/* Simulated Grid Cells */} - {Array.from({ length: 35 }).map((_, i) => { - const dayEvents = monthEventsByDay.get(i) ?? []; - return ( -
- {i < 31 ? i + 1 : ''} - {dayEvents.map((event) => ( -
- {event.time} {event.title} -
- ))} -
- ); - })} + {gridCells}
); From a0851e2392227c3abe48d829d0b648d74a644531 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Thu, 30 Jul 2026 14:59:28 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E2=9A=A1=20Bolt:=20Memoize=20calendar=20gr?= =?UTF-8?q?id=20generation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit