-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactoring the quries into a single one to get the search results on Home Page #4372
Refactoring the quries into a single one to get the search results on Home Page #4372
Conversation
}); | ||
const searchResultsToShow = useMemo(() => { | ||
let result: string[] | undefined = []; | ||
if (!searchResultsLoading) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also just say...
if (searchResultsData) {
....
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will also simplify the dependencies required for the useMemo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed and Commited
@@ -232,11 +206,11 @@ export const HomePageHeader = () => { | |||
autoCompleteStyle={styles.searchBox} | |||
entityRegistry={entityRegistry} | |||
/> | |||
{suggestionsToShow && suggestionsToShow.length > 0 && ( | |||
{searchResultsToShow && searchResultsToShow.length > 0 && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: we can simplify to
searchResultsToShow?.length > 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As We are using
let result: string[] | undefined = [];
That's why added check searchResultsToShow && searchResultsToShow.length > 0
.
Checklist