fix: remove invalid data to avoid rendering empty html nodes #31
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
The
Videos.jsx
component renders all the data fetched from youtube-v3 API, even if some of the properties are null. This caused react to render HTML nodes like<div></div>
. Although there is no data for these nodes, css is still applied to them, causing visual gap in the video grid on pages like Feed.Examples
Here is an example:
By further investigating the API endpoint for getting videos, it turns out that not only
videoId
andchannelId
are returned, but alsoplaylistId
.Here is a code snippet for viewing the "invalid" response data:
For me it returns:
As you can see, there is a field named
playlistId
under the fieldid
. Therefore I added a line of code to filter out those objects so that no empty nodes are rendered to produce visual gap.