Honglin fixed blank page problem in some accounts #3100
Merged
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.
Description
This PR addresses an issue where some user accounts were experiencing blank page when viewing their profile page and viewing dashboard. The root cause was unsafe property access on potentially null or undefined badge objects. The changes include updates to both the component logic and the corresponding test cases.
Main changes explained:
In Badges.jsx:
In FeaturedBadges.jsx:
In BadgeSummaryViz.jsx:
In BadgeHistory.jsx:
In Badges.test.jsx:
How to test:
npm install
and...
to run this PR locallyNote:
The error message showed in the blank page console log suggested the issue might be due to inconsistent or unexpected data structures. So I adjusted the Badges.jsx implementation to also handle a potentially nested badge structure. This approach aims to make the component more robust by accounting for different possible data formats, including both flat and nested structures. I also add additional null checks, using optional chaining, and ensuring the code can handle various badge object shapes, to prevent crashes caused by attempting to access properties on undefined objects.