Query hooks
UI components communicate with Sitecore Search API using query hooks available in the JS SDK package. This topic describes the query hook pattern with a request and a query result, and then lists the various query hooks available in the JS SDK.
Request
To populate and render merchandising widgets, you must use React hooks to attach the components to the ReactQuery singleton in WidgetProvider
.
The SDK provides a query hook for each type of merchandising widget. The following tables describe a typical query hook in the SDK:
Key |
Type |
Description |
---|---|---|
|
object |
Query function to be used. You can set additional request values to narrrow results. |
|
object |
Reference the React component receiving data. |
|
object |
Actions or callbacks used by the widget to populate request. Each widget type has its own list. |
|
object |
Parameters describing the state of the widget to be used by the search algorithm. |
|
object |
Contains the response object. A widget can only read its value. |
Query result
queryResult
is populated only while a query is running or after it has run. It contains various status values and the response.
Key |
Type |
Description |
---|---|---|
|
boolean |
If |
|
boolean |
If |
|
boolean |
If |
|
boolean |
If |
|
object |
Response object. |
Available query hooks
You can use the following query hooks in your application:
The JS SDK also includes secondary query hooks to support widgets, for example, list of widgets and breadcrumbs.