Skip to content

⚡ Bolt: Optimize derived state calculation in notifications#34

Open
sshahriazz wants to merge 1 commit intomainfrom
jules/performance-usememo-notifications-3134937155069941456
Open

⚡ Bolt: Optimize derived state calculation in notifications#34
sshahriazz wants to merge 1 commit intomainfrom
jules/performance-usememo-notifications-3134937155069941456

Conversation

@sshahriazz
Copy link
Collaborator

💡 What: Refactored NotificationMenu and NotificationTabPanel to use useMemo instead of useState + useEffect for categorizing notifications into today and older groups.

🎯 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 notificationsData changes. 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

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>
@google-labs-jules
Copy link

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant