West Midlands | 26 March SDC | Iswat Bello | Sprint 1 | Purple Forest/bug report/Hashtag slowing down my browser#215
Open
Iswanna wants to merge 1 commit into
Conversation
Added a guard clause to hashtagView to check if the hashtag has changed before clearing the UI and fetching data. This stops the infinite loop caused by state updates triggering route changes.
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.
Learners, PR Template
Self checklist
Changelist
This PR resolves the infinite flickering issue on hashtag pages by implementing a guard clause within the hashtagView function. This prevents a circular logic loop where state updates were triggering redundant route changes and repeated API requests.
The Problem: When visiting a hashtag page, the application became stuck in an infinite loop. The screen would flash blank repeatedly, and the Network tab showed continuous API requests to the same endpoint.
The Discovery: I traced the logic through
index.mjs,router.mjs, andhashtag.mjs.hashtagViewwas calling the API every time it ran. The API updated the state, which triggered astate-changeevent. Theindex.mjslistener heard this event and told the router to run again, starting the cycle over.destroy()function was being called at the start of every loop iteration, wiping the screen before the data could be rendered.The Fix:
hashtagView.mjs.currentHashtagin the state.Verification: