Skip to content

refactor: optimize Zustand cart store subscriptions#516

Open
hashhhh-16 wants to merge 2 commits into
niharika-mente:mainfrom
hashhhh-16:refactor/zustand-cart-rerenders
Open

refactor: optimize Zustand cart store subscriptions#516
hashhhh-16 wants to merge 2 commits into
niharika-mente:mainfrom
hashhhh-16:refactor/zustand-cart-rerenders

Conversation

@hashhhh-16

Copy link
Copy Markdown
Contributor

Summary

Optimized Zustand cart store subscriptions to reduce unnecessary component re-renders.

Changes

  • Updated ProductCard to subscribe only to addToCart using a selector.
  • Updated QuickViewModal to subscribe only to addToCart using a selector.
  • Updated Navbar to use the existing selector-based useCart() hook instead of directly destructuring from useCartStore().

Benefits

  • Components now subscribe only to the state slices they need.
  • Reduces unnecessary re-renders when cart state changes.
  • Aligns cart consumers with Zustand best practices.

closes #437

@vercel

vercel Bot commented Jun 27, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the niharika-mente's projects Team on Vercel.

A member of the Team first needs to authorize it.

Aamod007
Aamod007 previously approved these changes Jul 2, 2026

@Aamod007 Aamod007 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Aamod007 Aamod007 self-requested a review July 2, 2026 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: optimize Zustand store to prevent unnecessary component re-renders on cart updates

2 participants