API Reference
/
React InstantSearch Hooks
/
useConnector()
May. 12, 2022
useConnector()
Signature
useConnector(connector: Connector, props: object) => ConnectorApi
About this Hook
A React Hook that lets you use an InstantSearch connector in a React component.
You can use this if you want to connect your own connectors to React InstantSearch Hooks.
Examples
Copy
1
2
3
4
5
6
7
8
9
10
11
12
import { useConnector } from 'react-instantsearch-hooks-web';
import connectGeoSearch from 'instantsearch.js/es/connectors/geo-search/connectGeoSearch';
export function useGeoSearch(props) {
return useConnector(connectGeoSearch, props);
}
export function GeoSearch(props) {
const { items, refine } = useGeoSearch(props);
return <>{/* Your JSX */}</>;
}
Parameters
connector
|
type: Connector
Required
The InstantSearch connector to use. |
props
|
type: object
The props to pass to the InstantSearch widget. |
Returns
...connectorApi
|
type: object
The connector API, such as state and functions. |
Did you find this page helpful?