This repository was archived by the owner on Oct 4, 2022. It is now read-only.
P1 345 woo shopping data in google preview#1118
Merged
JoseeWouters merged 25 commits intodevelopfrom Apr 12, 2021
Merged
Conversation
…github.com/Yoast/javascript into P1-345-Woo-shopping-data-in-google-preview
igorschoester
suggested changes
Mar 31, 2021
packages/search-metadata-previews/src/snippet-preview/ProductDataDesktop.js
Outdated
Show resolved
Hide resolved
packages/search-metadata-previews/src/snippet-preview/ProductDataDesktop.js
Outdated
Show resolved
Hide resolved
packages/search-metadata-previews/src/snippet-preview/ProductDataDesktop.js
Outdated
Show resolved
Hide resolved
packages/search-metadata-previews/src/snippet-preview/ProductDataDesktop.js
Outdated
Show resolved
Hide resolved
packages/search-metadata-previews/src/snippet-preview/ProductDataDesktop.js
Outdated
Show resolved
Hide resolved
packages/search-metadata-previews/src/snippet-preview/ProductDataDesktop.js
Outdated
Show resolved
Hide resolved
packages/search-metadata-previews/src/snippet-preview/ProductDataDesktop.js
Outdated
Show resolved
Hide resolved
packages/search-metadata-previews/src/snippet-preview/SnippetPreview.js
Outdated
Show resolved
Hide resolved
packages/search-metadata-previews/src/snippet-preview/SnippetPreview.js
Outdated
Show resolved
Hide resolved
igorschoester
suggested changes
Apr 7, 2021
packages/search-metadata-previews/src/snippet-preview/ProductDataDesktop.js
Outdated
Show resolved
Hide resolved
packages/search-metadata-previews/src/snippet-preview/ProductDataDesktop.js
Outdated
Show resolved
Hide resolved
Comment on lines
735
to
753
| if ( shoppingData !== {} ) { | ||
|
|
||
| if ( mode === MODE_DESKTOP ) { | ||
| return ( | ||
| <ProductDataDesktop | ||
| shoppingData={ shoppingData } | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| if ( mode === MODE_MOBILE ) { | ||
| return ( | ||
| <ProductDataMobile | ||
| shoppingData={ shoppingData } | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| return null; |
Contributor
There was a problem hiding this comment.
A couple of things:
- You can not compare an object to an empty different object. It compares the memory address and thus will never be the same. You can work around this by checking if there are any values for example.
- You can early return on the shoppingData check so you don't have to indent for all the rest. This improves readability of your code.
- You are missing a return for when the shoppingData is empty, that will be
undefinedinstead ofnullin your current code. That is not a problem in behavior, but it is not correct.
Suggested change
| if ( shoppingData !== {} ) { | |
| if ( mode === MODE_DESKTOP ) { | |
| return ( | |
| <ProductDataDesktop | |
| shoppingData={ shoppingData } | |
| /> | |
| ); | |
| } | |
| if ( mode === MODE_MOBILE ) { | |
| return ( | |
| <ProductDataMobile | |
| shoppingData={ shoppingData } | |
| /> | |
| ); | |
| } | |
| return null; | |
| if ( Object.values( shoppingData ).length === 0 ) { | |
| return null; | |
| } | |
| if ( mode === MODE_DESKTOP ) { | |
| return ( | |
| <ProductDataDesktop | |
| shoppingData={ shoppingData } | |
| /> | |
| ); | |
| } | |
| if ( mode === MODE_MOBILE ) { | |
| return ( | |
| <ProductDataMobile | |
| shoppingData={ shoppingData } | |
| /> | |
| ); | |
| } | |
| return null; |
Co-authored-by: Igor <35524806+igorschoester@users.noreply.github.com>
…github.com/Yoast/javascript into P1-345-Woo-shopping-data-in-google-preview
Contributor
|
Acceptance 👍 |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
This PR can be summarized in the following changelog entry:
Relevant technical choices:
Test instructions
This PR can be tested by following these steps:
Impact check
UI changes
Quality assurance
Fixes P1-345