perf(rewards): memoize RewardHistory list and add lazy pagination - #2160
Open
baedboibidex-cmyk wants to merge 1 commit into
Open
perf(rewards): memoize RewardHistory list and add lazy pagination#2160baedboibidex-cmyk wants to merge 1 commit into
baedboibidex-cmyk wants to merge 1 commit into
Conversation
The RewardHistory component was rendering all claim rows on every render and recomputing its derived sorted list unconditionally. This caused unnecessary work for users with long claim histories. - Wrap the sorted claim list in useMemo keyed on the claims array so it only recomputes when inputs change - Extract each table row into a React.memo-wrapped RewardRow component to skip re-renders when claim data hasn't changed - Add incremental load-more pagination (PAGE_SIZE = 10) so only visible rows mount in the DOM at any time - Add comprehensive test suite (18 tests) covering empty state, sorting, pagination boundaries, copy button, and negative cases Closes EarnQuestOne#2152 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
Contributor
|
Well done on the job done so far! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves #2152 — memoizes the RewardHistory component and adds incremental load-more pagination so only visible rows are mounted in the DOM.
What changed
claimsarray rendered on every parent re-renderuseMemoon sorted list +React.memoper rowPAGE_SIZE(10) rows mounted; "Load More" loads the next batchclaimschangesChanges
FrontEnd/my-app/components/rewards/RewardHistory.tsxuseMemofor the sorted claim list (newest-first), keyed onclaims<tr>into aReact.memo-wrappedRewardRowcomponent — skips re-renders when claim data is unchangeduseCallbackonhandleLoadMoreto keep the handler referentially stableFrontEnd/my-app/components/rewards/__tests__/RewardHistory.test.tsx(new)@testing-library/react, co-located__tests__/directoryPerformance impact
<tr>rows + all children mounted<tr>rows on first renderclaimsarray changesVerification
useReputation.test.tsx)Acceptance criteria
🤖 Generated with Codebuff
Co-Authored-By: Codebuff noreply@codebuff.com