Skip to content

Commit 63cef9b

Browse files
committed
chore(search): wrap hits ourselves
1 parent d5a4ee6 commit 63cef9b

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

js/src/lib/Search/Results.js

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
11
import React from 'react';
22
import { createConnector } from 'react-instantsearch';
33
import {
4-
Hits,
54
Pagination,
65
CurrentRefinements,
76
Stats,
87
} from 'react-instantsearch/es/dom';
8+
import { connectHits } from 'react-instantsearch/es/connectors';
99

1010
import Hit from '../Hit';
1111
import { isEmpty } from '../util';
1212

1313
const body = document.querySelector('body');
1414

15+
const Hits = connectHits(({ hits, onTagClick, onOwnerClick }) =>
16+
hits.map(hit => (
17+
<Hit
18+
onTagClick={onTagClick}
19+
onOwnerClick={onOwnerClick}
20+
hit={hit}
21+
key={hit.objectID}
22+
/>
23+
))
24+
);
25+
1526
const ResultsFound = ({ pagination, onTagClick, onOwnerClick }) => (
1627
<div className="container">
1728
<div className="mx-3">
@@ -28,16 +39,7 @@ const ResultsFound = ({ pagination, onTagClick, onOwnerClick }) => (
2839
}}
2940
/>
3041
</div>
31-
<Hits
32-
hitComponent={({ hit }) => (
33-
<Hit
34-
onTagClick={onTagClick}
35-
onOwnerClick={onOwnerClick}
36-
hit={hit}
37-
key={hit.objectID}
38-
/>
39-
)}
40-
/>
42+
<Hits onTagClick={onTagClick} onOwnerClick={onOwnerClick} />
4143
<div className="d-flex">
4244
{pagination ? (
4345
<Pagination showFirst={false} showLast={false} scrollTo={true} />

0 commit comments

Comments
 (0)