Skip to content

Memoize and virtualize MyCommitmentsGrid and MarketplaceGrid to remove large-list render jank#1192

Open
greatest0fallt1me wants to merge 1 commit into
Commitlabs-Org:masterfrom
greatest0fallt1me:fix/issue-600
Open

Memoize and virtualize MyCommitmentsGrid and MarketplaceGrid to remove large-list render jank#1192
greatest0fallt1me wants to merge 1 commit into
Commitlabs-Org:masterfrom
greatest0fallt1me:fix/issue-600

Conversation

@greatest0fallt1me

Copy link
Copy Markdown
Contributor

Fixes #600

Summary

  • Wrap MyCommitmentsGrid and MarketplaceGrid in React.memo to prevent re-renders when unrelated parent state changes (cards were already memoized via React.memo).
  • Add useMemo-driven filterFn/sortFn props so derived lists are only recomputed when commitments/items or the predicate references change, eliminating redundant work on every parent render.
  • Apply CSS content-visibility: auto per card when list length exceeds 50 items — a zero-dependency windowing approach that lets the browser skip layout/paint for off-screen rows while preserving DOM presence for accessibility and SSR compatibility.
  • Add tests/components/MyCommitmentsGrid.perf.test.tsx covering memoized re-render prevention, filter/sort correctness, empty/single/large-list edge cases, and rapid filter toggling for both grid components.

Changes

  • src/components/MyCommitmentsGrid.tsx — memoized grid, useMemo for filterFn/sortFn, CSS windowing for large lists.
  • src/components/MarketplaceGrid.tsx — same treatment; memo() wrapper, useMemo, CSS windowing.
  • tests/components/MyCommitmentsGrid.perf.test.tsx — new perf/memoization test suite with 12 test cases covering both grid components.

Test plan

  • Run npm test / pnpm test — all existing tests pass, new perf tests pass.
  • Verify empty state renders correctly for both grids.
  • Verify skeleton components (MyCommitmentsGridSkeleton, MarketplaceGridSkeleton) are unaffected.
  • Test with a large mock dataset (100+ items) — no visible jank during filter/sort changes.
  • Confirm filterFn/sortFn props are optional (backwards-compatible; existing callers require no changes).

🤖 Generated with Claude Code

… remove large-list render jank

- Wrap both grid components in React.memo to prevent re-renders when
  unrelated parent state changes; MyCommitmentCard and MarketplaceCard
  were already memoized.
- Add useMemo-driven filterFn/sortFn props so derived lists are only
  recomputed when commitments/items or the predicate references change,
  eliminating redundant work on every parent render.
- Apply CSS content-visibility: auto per card when list length exceeds 50
  items — a zero-dependency windowing approach that lets the browser skip
  layout/paint for off-screen rows while preserving DOM for a11y and SSR.
- Add tests/components/MyCommitmentsGrid.perf.test.tsx covering memoized
  re-render prevention, filter/sort correctness, empty/single/large list
  edge cases, and rapid filter toggling for both grid components.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown

@greatest0fallt1me is attempting to deploy a commit to the 1nonly's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

Memoize and virtualize MyCommitmentsGrid and MarketplaceGrid to remove large-list render jank

1 participant