⚡ Bolt: Optimize derived state calculation in notifications#34
⚡ Bolt: Optimize derived state calculation in notifications#34sshahriazz wants to merge 1 commit intomainfrom
Conversation
Replaced unnecessary `useState` + `useEffect` chains with `useMemo` in `NotificationMenu.tsx` and `NotificationTabPanel.tsx`. This optimization prevents double-render cycles and reduces CPU overhead when calculating derived state. Co-authored-by: sshahriazz <34005640+sshahriazz@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
💡 What: Refactored
NotificationMenuandNotificationTabPanelto useuseMemoinstead ofuseState+useEffectfor categorizing notifications intotodayandoldergroups.🎯 Why: Using an effect to map/reduce props into local state causes an unnecessary double-render cycle. The first render shows the initial state (empty arrays), the effect runs, sets the state, and triggers a second render with the derived data. This wastes CPU cycles and can cause layout shifts.
📊 Impact: Reduces re-renders by 50% for these components when they mount or when
notificationsDatachanges. The calculation now happens synchronously during the render phase.🔬 Measurement: Verify by mounting the components or updating the notification data; React DevTools will show one render pass instead of two.
PR created automatically by Jules for task 3134937155069941456 started by @sshahriazz