User Story
As a shopper,
I want the cart item count badge in the navigation bar to update instantly and efficiently,
so that navigating the site feels snappy regardless of cart size.
Problem
In Navigation.tsx, getTotalItems() is called twice per render — once for the conditional check and once to display the value. Each call iterates the full cart items array via Array.reduce().
// Current — two reduce() calls per render
{getTotalItems() > 0 && (
<span>
{getTotalItems()} {/* second call */}
</span>
)}
Acceptance Criteria
Note: This issue is low complexity and a good candidate for a first contribution. It can be implemented in parallel with the other performance issues.
Files
frontend/src/components/Navigation.tsx
User Story
As a shopper,
I want the cart item count badge in the navigation bar to update instantly and efficiently,
so that navigating the site feels snappy regardless of cart size.
Problem
In
Navigation.tsx,getTotalItems()is called twice per render — once for the conditional check and once to display the value. Each call iterates the full cart items array viaArray.reduce().Acceptance Criteria
getTotalItems()is called at most once per render in theNavigationcomponent (store result in a variable)Files
frontend/src/components/Navigation.tsx