Skip to content

Memoize MyCommitmentsGrid and MarketplaceGrid cards to remove re-render jank on filtering #659

Description

@1nonlypiece

📌 Description

src/components/MyCommitmentsGrid.tsx and src/components/MarketplaceGrid.tsx
re-render every card on each filter/sort change because card components are not
memoized and inline callbacks/derived data are recreated on each render. With
large lists this produces visible jank during filtering.

This issue memoizes card components and stabilizes derived data/callbacks so only
changed cards re-render.

🎯 Requirements and Context

  • Wrap MyCommitmentCard and MarketplaceCard in React.memo with stable props.
  • Memoize filtered/sorted derivations with useMemo; stabilize callbacks with
    useCallback.
  • Use stable keys (not array index) for list items.
  • No behaviour change; measurable reduction in re-renders.

🛠️ Suggested Execution

1. Fork the repo and create a branch

git checkout -b perf/memoize-grids

2. Implement changes

  • Apply memoization to the two grids and their cards.
  • Add src/components/__tests__/GridMemoization.test.tsx using render counters /
    spies to assert unchanged cards do not re-render on filter changes.
  • Add docs/performance/GRID_RENDER.md documenting the before/after render counts.
  • Validate filtering/sorting still works identically.

3. Test and commit

  • Run pnpm test.
  • Cover edge cases: empty results, single-item change, full-list change,
    sort-only change.

Example commit message

perf: memoize MyCommitmentsGrid and MarketplaceGrid cards

✅ Guidelines

  • Minimum 95% test coverage on new/changed lines.
  • Clear, reviewer-friendly documentation.
  • Timeframe: 96 hours.

🏷️ Labels

type-performance · area-frontend · MAYBE REWARDED · GRANTFOX OSS ·
OFFICIAL CAMPAIGN

💬 Community & Support

  • Join the CommitLabs contributor Discord to coordinate and get unblocked fast:
    https://discord.gg/WV7tdYkJk
  • Introduce yourself before starting so we can avoid duplicate work and pair you
    with a reviewer. Maintainers triage actively and review fast.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions