<InstantSearch indexName={string} searchClient={object} // Optional parameters searchState={object} resultsState={object} createURL={function} onSearchStateChange={function} refresh={boolean} stalledSearchDelay={number} root={object} />
About this widget #
InstantSearch
is the root component of all React InstantSearch implementations. It provides to all the connected components (or widgets) a way to interact with the searchState
.
Examples #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import algoliasearch from 'algoliasearch/lite';
import { InstantSearch } from 'react-instantsearch-dom';
const searchClient = algoliasearch(
'AJ0P3S7DWQ',
'90dfaaf5755e694f341fe68f6e41a6d4'
);
const App = () => (
<InstantSearch
indexName="instant_search"
searchClient={searchClient}
>
{/* Widgets */}
</InstantSearch>
);
Props #
indexName
# |
type: string
Required
The main index in which to search. |
||
Copy
|
|||
searchClient
# |
type: object
Required
Provides a search client to |
||
Copy
|
|||
searchState
# |
type: object
Optional
Injects a |
||
Copy
|
|||
resultsState
# |
type: object
Optional
Injects the results that are used at first rendering. Those results are found by using the |
||
Copy
|
|||
createURL
# |
type: function
Optional
This function is called when |
||
Copy
|
|||
onSearchStateChange
# |
type: function
Optional
A function called every time a state change happens. The callback is called with the |
||
Copy
|
|||
refresh
# |
type: boolean
Optional
Whether the cache needs to be cleared so that the front end is updated when a change occurs in the index. |
||
Copy
|
|||
stalledSearchDelay
# |
type: number
default: 200
Optional
The amount of time before considering that the search is stalled. This value impacts the prop |
||
Copy
|
|||
root
# |
type: object
default: { Root: "div" }
Optional
Updates the element that is created by |
||
Copy
|
HTML output#
1
2
3
<div class="ais-InstantSearch__root">
<!-- Widgets -->
</div>