ais-infinite-hits
<ais-infinite-hits // Optional parameters :escapeHTML="boolean" :show-previous="boolean" :class-names="object" :transform-items="function" :cache="object" />
About this widget
The ais-infinite-hits
widget is used to display a list of results with a “Show more” button.
To configure the number of hits to show, use the ais-hits-per-page
widget or the ais-configure
widget.
Examples
1
<ais-infinite-hits />
Props
escapeHTML
|
type: boolean
default: true
Optional
Whether to escape the raw HTML in the hits. |
||
Copy
|
|||
show-previous
|
type: boolean
default: false
Optional
Enable the button to load previous results. The button is only displayed if the routing option is enabled in |
||
Copy
|
|||
class-names
|
type: object
default: {}
Optional
The CSS classes to override.
|
||
Copy
|
|||
transform-items
|
type: function
default: items => items
Optional
Receives the items and is called before displaying them. Should return a new array with the same shape as the original array. Useful for transforming, removing, or reordering items. In addition, the full If you’re transforming an attribute using the When using an array, take steps to avoid creating infinite loops. When you use an array as a prop, it causes the widget to re-register on every render, and this can sometimes cause these infinite loops. |
||
Copy
|
|||
cache
|
type: object
default: in-memory cache object
Optional
The widget internally caches all loaded hits. By default, it uses its own internal in-memory cache implementation. We provide another implementation which uses sessionStorage, which is more persistent and lets you restore the scroll position when you leave and come back to the search page. You can also provide your own implementation by providing a cache object with |
||
Copy
|
Customize the UI
default
|
The slot to override the complete DOM output of the widget. Note that when you implement this slot, none of the other slots will change the output, as the default slot surrounds them. Scope
|
||
Copy
|
|||
loadPrevious
|
The slot to override the DOM output of the “Show previous” button. Scope
|
||
Copy
|
|||
item
|
The slot to override the DOM output of the item. Scope
|
||
Copy
|
|||
loadMore
|
The slot to override the DOM output of the “Show more” button. Scope
|
||
Copy
|
HTML output
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<div class="ais-InfiniteHits">
<button class="ais-InfiniteHits-loadPrevious">
Show previous results
</button>
<ol class="ais-InfiniteHits-list">
<li class="ais-InfiniteHits-item">
...
</li>
<li class="ais-InfiniteHits-item">
...
</li>
<li class="ais-InfiniteHits-item">
...
</li>
</ol>
<button class="ais-InfiniteHits-loadMore">
Show more results
</button>
</div>
Sending Click and Conversion events
Please refer to the guide on Sending Insight Events to learn about sending events from any InstantSearch widget.