usePredictiveSearch
The usePredictiveSearch
function is a React hook used to show search results as the user types.
Usage
import { usePredictiveSearch } from "builderoo";
const { results, query, setQuery, loading } = usePredictiveSearch({types: ["product"]})
Parameters
Name | Type | Description |
---|---|---|
types | string[] | One or more of product , collection , article |
Return Values
Name | Type | Description |
---|---|---|
results | SearchResult* | The search results. |
query | string | Current search query. Used to show query in the search box or elsewhere. |
setQuery | function | Used to set the search query as the user types. |
loading | boolean | If the search is currently loading |
*In predictive search only _id
, title
, route
and image
properties are available.