API Reference
/
React InstantSearch Hooks
/
useStats()
Sep. 12, 2022
useStats()
About this Hook
The useStats
Hook isn’t currently available in React InstantSearch Hooks, but you can make it yourself using useConnector()
along with connectStats
.
Refer to the connectStats
documentation for the full API reference.
Examples
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { useConnector } from 'react-instantsearch-hooks-web';
import connectStats from 'instantsearch.js/es/connectors/stats/connectStats';
export function useStats(props) {
return useConnector(connectStats, props);
}
export function Stats(props) {
const {
hitsPerPage,
nbHits,
areHitsSorted,
nbSortedHits,
nbPages,
page,
processingTimeMS,
query,
} = useStats(props);
return <>{/* Your JSX */}</>;
}
Did you find this page helpful?