Skip to content

Commit 544ff5c

Browse files
committedSep 21, 2015
fix(Hits): handle the display when there is no result
1 parent 97b1681 commit 544ff5c

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed
 

‎components/Hits.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,15 @@ class Hits extends React.Component {
1414

1515
renderNoResults() {
1616
return (
17-
<div><Template template={this.props.noResultsTemplate} /></div>
17+
<div><Template data={this.props.results} template={this.props.noResultsTemplate} /></div>
1818
);
1919
}
2020

2121
render() {
22-
var renderedHits = map(this.props.hits, function(hit) {
23-
return <Template data={hit} key={hit.objectID} template={this.props.hitTemplate} />;
24-
}, this);
25-
26-
return <div>{renderedHits}</div>;
22+
if (this.props.hits.length > 0) {
23+
return this.renderWithResults();
24+
}
25+
return this.renderNoResults();
2726
}
2827
}
2928

‎widgets/hits.js

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ function hits({container = null, templates = {}, hitsPerPage = 20}) {
1313
React.render(
1414
<Hits
1515
hits={results.hits}
16+
results={results}
1617
helper={helper}
1718
noResultsTemplate={templates.empty}
1819
hitTemplate={templates.hit}

0 commit comments

Comments
 (0)