Hooks
Ez az oldal még csak angolul érhető el.
The hooks of @poltura/theme-sdk/search.
Ezen az oldalon
import { … } from '@poltura/theme-sdk/search';useSearch
The shopper's search: what they typed, debounced product results, suggestions and featured products.
useSearch(options?: SearchOptions): SearchStateSubmitting records the search event and opens the product listing for the query.
Parameters
options?: SearchOptions: The result limit, the popular searches and the featured collection.
Returns: The search state and the actions that change it.
Example
import { useSearch } from '@poltura/theme-sdk/search';
export function SearchBox() {
const search = useSearch({ limit: 5 });
return (
<form onSubmit={(event) => { event.preventDefault(); search.submit(); }}>
<input value={search.query} onChange={(event) => search.setQuery(event.target.value)} />
<ul>{search.results.map((product) => <li key={product.id}>{product.title}</li>)}</ul>
</form>
);
}