Skip to content

Commit

Permalink
Domain Picker: Fix useDomainSuggestions warning (#97897)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla authored Jan 10, 2025
1 parent 5b85eb3 commit 5f3994d
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions packages/domain-picker/src/hooks/use-domain-suggestions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ export function useDomainSuggestions(
invalidateResolutionForStoreSelector: ( selectorName: string ) => void;
};

return useSelect(
const retryRequest = (): void => {
invalidateResolutionForStoreSelector( '__internalGetDomainSuggestions' );
};

const domainSuggestions = useSelect(
( select ) => {
if ( ! domainSearch || domainSearch.length < DOMAIN_QUERY_MINIMUM_LENGTH ) {
return;
Expand All @@ -43,10 +47,6 @@ export function useDomainSuggestions(
getDomainErrorMessage,
}: DomainSuggestionsSelect = select( DOMAIN_SUGGESTIONS_STORE );

const retryRequest = (): void => {
invalidateResolutionForStoreSelector( '__internalGetDomainSuggestions' );
};

const allDomainSuggestions = getDomainSuggestions( domainSearch, {
// Avoid `only_wordpressdotcom` — it seems to fail to find results sometimes
include_wordpressdotcom: true,
Expand All @@ -61,8 +61,17 @@ export function useDomainSuggestions(

const errorMessage = getDomainErrorMessage();

return { allDomainSuggestions, state, errorMessage, retryRequest };
return { allDomainSuggestions, state, errorMessage };
},
[ domainSearch, domainCategory, quantity, locale, extraOptions ]
);

if ( ! domainSuggestions ) {
return;
}

return {
...domainSuggestions,
retryRequest,
};
}

0 comments on commit 5f3994d

Please sign in to comment.