Repository navigation
Fix Trending column piling up duplicate rows - #574
Merged
Merged
Conversation
TrendsList keys its rows by trend name, and trends/plus.json sometimes returns the same name twice. With two rows sharing a key, React 16 leaves a stale row behind whenever the order above them changes, so the copies pile up until the tab is reloaded. Keep only the first trend of each name before rendering. Ranks and order are unchanged.
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.
The Trending column sometimes shows the same trend many times, and the copies keep piling up until the tab is reloaded.
Cause
TrendsListrenders its rows withkey: e.name, andtrends/plus.jsonsometimes returns the same trend name twice. With two rows sharing a key, React 16 loses track of one of the old rows whenever the order above them changes, so each such refresh leaves one stale row behind.Fix
Keep only the first trend of each name before rendering (one spot in
files/bundle.js). Ranks and order are unchanged.How it was tested
TrendsListrender callback fromfiles/bundle.jswas called with six trends named A, B, A, C, B, D: 6 rows before (two pairs of duplicate keys), 4 rows after (A, B, C, D).There is no console error to attach: the production React build does not warn about duplicate keys.
In daily use, dropping the repeated names from the response before OTD renders it (the same effect as this change) stopped the pile-up for me.
Not tested: the patched bundle in a live, logged-in OTD session.
I used Claude (an AI assistant) to track this down, write the fix and run the tests above.