Skip to content

Commit

Permalink
fix(Hits): limit the hitComponent to be only a function (#1912)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaa123 authored and bobylito committed Jan 27, 2017
1 parent 8480edd commit b3c9578
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 25 deletions.
6 changes: 1 addition & 5 deletions packages/react-instantsearch/src/components/Hits.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ class Hits extends Component {

Hits.propTypes = {
hits: PropTypes.array,

hitComponent: PropTypes.oneOfType([
PropTypes.string,
PropTypes.func,
]).isRequired,
hitComponent: PropTypes.func.isRequired,
};

Hits.defaultProps = {
Expand Down
7 changes: 5 additions & 2 deletions packages/react-instantsearch/src/components/Hits.test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
/* eslint-env jest, jasmine */

import React from 'react';
import React, {PropTypes} from 'react';
import renderer from 'react-test-renderer';

import Hits from './Hits';

describe('Hits', () => {
it('accepts a hitComponent prop', () => {
const hits = [{objectID: 0}, {objectID: 1}, {objectID: 2}];
const Hit = 'Hit';
const Hit = ({hit}) => <div id={hit.objectID}/>;
Hit.propTypes = {
hit: PropTypes.object,
};
const tree = renderer.create(
<Hits
hitComponent={Hit}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
exports[`Hits accepts a hitComponent prop 1`] = `
<div
className="ais-Hits__root">
<Hit
hit={
Object {
"objectID": 0,
}
} />
<Hit
hit={
Object {
"objectID": 1,
}
} />
<Hit
hit={
Object {
"objectID": 2,
}
} />
<div
id={0} />
<div
id={1} />
<div
id={2} />
</div>
`;

0 comments on commit b3c9578

Please sign in to comment.