Skip to content

Commit b3c9578

Browse files
mikaa123bobylito
authored andcommitted
fix(Hits): limit the hitComponent to be only a function (#1912)
1 parent 8480edd commit b3c9578

File tree

3 files changed

+12
-25
lines changed

3 files changed

+12
-25
lines changed

packages/react-instantsearch/src/components/Hits.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@ class Hits extends Component {
1818

1919
Hits.propTypes = {
2020
hits: PropTypes.array,
21-
22-
hitComponent: PropTypes.oneOfType([
23-
PropTypes.string,
24-
PropTypes.func,
25-
]).isRequired,
21+
hitComponent: PropTypes.func.isRequired,
2622
};
2723

2824
Hits.defaultProps = {

packages/react-instantsearch/src/components/Hits.test.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
/* eslint-env jest, jasmine */
22

3-
import React from 'react';
3+
import React, {PropTypes} from 'react';
44
import renderer from 'react-test-renderer';
55

66
import Hits from './Hits';
77

88
describe('Hits', () => {
99
it('accepts a hitComponent prop', () => {
1010
const hits = [{objectID: 0}, {objectID: 1}, {objectID: 2}];
11-
const Hit = 'Hit';
11+
const Hit = ({hit}) => <div id={hit.objectID}/>;
12+
Hit.propTypes = {
13+
hit: PropTypes.object,
14+
};
1215
const tree = renderer.create(
1316
<Hits
1417
hitComponent={Hit}
Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
11
exports[`Hits accepts a hitComponent prop 1`] = `
22
<div
33
className="ais-Hits__root">
4-
<Hit
5-
hit={
6-
Object {
7-
"objectID": 0,
8-
}
9-
} />
10-
<Hit
11-
hit={
12-
Object {
13-
"objectID": 1,
14-
}
15-
} />
16-
<Hit
17-
hit={
18-
Object {
19-
"objectID": 2,
20-
}
21-
} />
4+
<div
5+
id={0} />
6+
<div
7+
id={1} />
8+
<div
9+
id={2} />
2210
</div>
2311
`;

0 commit comments

Comments
 (0)