Skip to content

Consolidate useThemeSettings calls in badge components (#431)#348

Merged
paul-phan merged 2 commits intomainfrom
paul-dev
Mar 6, 2026
Merged

Consolidate useThemeSettings calls in badge components (#431)#348
paul-phan merged 2 commits intomainfrom
paul-dev

Conversation

@paul-phan
Copy link
Member

Summary

Optimizes badge components to reduce ThemeSettingsStore subscriptions and prevent "Maximum listeners exceeded" warnings.

Changes

badges.tsx

  • Added "BadgeStyleSettings" interface for shared badge styling props
  • Refactored all badge components to receive settings as props (pure components):
    • Badge, NewBadge, BestSellerBadge, SoldOutBadge, BundleBadge, SaleBadge
  • ProductBadges now calls useThemeSettings() once and passes all settings to children
  • Removed 6 useThemeSettings() calls per product card

product-card.tsx

  • Extended useThemeSettings() destructuring to include all badge-related settings
  • Creates badgeStyle object and passes all required props to badge components

single-product/index.tsx

  • Replaced standalone placeholder with inline span
  • Avoids needing a store subscription for static demo content

Impact

  • Subscriptions per product card: 7 → 2
  • Product grid (10 items): ~70 listeners → ~20 listeners
  • No more "Maximum listeners exceeded" warnings on product listing pages
  • Cleaner architecture: parent fetches, children receive via props

Related

…431)

Reduced from 6 useThemeSettings() subscriptions per product card to 1.
Badge components now receive theme settings as props instead of subscribing
individually. Updated product-card.tsx and single-product/index.tsx to pass
required props to badge components.
@changeset-bot
Copy link

changeset-bot bot commented Mar 5, 2026

⚠️ No Changeset found

Latest commit: 890a24d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@paul-phan paul-phan marked this pull request as ready for review March 5, 2026 10:27
@paul-phan paul-phan requested a review from hta218 March 5, 2026 10:27
@hta218 hta218 changed the title perf: consolidate useThemeSettings calls in badge components (#431) Consolidate useThemeSettings calls in badge components (#431) Mar 5, 2026
@paul-phan paul-phan merged commit 08a3544 into main Mar 6, 2026
2 checks passed
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.

Fix: ThemeSettingsStore Maximum listeners (100) exceeded - Possible memory leak

1 participant