Complementary query hooks

Secondary query hooks work independently or in the presence of query hooks that populate widgets. You can use them to retrieve supplementary data for a variety of use cases.

usePageWidgets

You can use this hook to retrieve the rfkid of all widgets configured in the CEC for the host page. The WidgetsContainer component uses this hook for the list of widgets, it renders.

The hook returns the following:

RequestResponse
{
    isLoading, // The query has no data and is currently fetching
    isError,// The query encountered an error
    isSuccess, // The query was successful and data is available
    isFetching, // In any state, if the query is fetching at any time (including background refetching) isFetching is true.
    data: {
        widgets [string], // array of rfkid
    }
}

useSearchResultsBreadcrumb

You can use this hook on product listing pages to complement the useSearchResults hook, it returns the taxonomy for the host page. Sorted in the order they appear in the URL, each item represents a URL segment.

The hook returns the following:

RequestResponse
[
    {
        "category_id": "<id for item 0>",
        "name": "<Name for item 0>",
        "url_path": "<path for item 0>"
    },
    ...
    {
        "category_id": "<id for item N>",
        "name": "<Name for item N>",
        "url_path": "<path for item N>"
    }
]

In the UI reference site, in the Templates section, in SearchResults, the SearchResultsRowGrid demo uses this query hook.

useSearchResultsIsSelectedFacet

You can use this hook to complement the useSearchResults hook. It returns true if a facet has been selected in the search result widget.

RequestResponse
boolean // true if a facet has been selected in the search results widget on the page 

useSearchResultsSelectedFacets

You can use this hook to complement the useSearchResults hook to retrieve additional information about the facets selected in the search results widget.

The hook returns the following where each item is a selected facet:

RequestResponse
[ 
   {
       id: string,
       name: string,
       numberOfProducts: number,
       values: [
           {
               id: string,
               text: string
           }
       ]
   }
]
Note

A page can contain only one search results widget. At runtime, this query hook recognizes the useSearchResults hook on the page.

Do you have some feedback for us?

If you have suggestions for improving this article,