Skip to content

Commit

Permalink
fix(Hits): handle the display when there is no result
Browse files Browse the repository at this point in the history
  • Loading branch information
maxiloc committed Sep 21, 2015
1 parent 97b1681 commit 544ff5c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
11 changes: 5 additions & 6 deletions components/Hits.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@ class Hits extends React.Component {

renderNoResults() {
return (
<div><Template template={this.props.noResultsTemplate} /></div>
<div><Template data={this.props.results} template={this.props.noResultsTemplate} /></div>
);
}

render() {
var renderedHits = map(this.props.hits, function(hit) {
return <Template data={hit} key={hit.objectID} template={this.props.hitTemplate} />;
}, this);

return <div>{renderedHits}</div>;
if (this.props.hits.length > 0) {
return this.renderWithResults();
}
return this.renderNoResults();
}
}

Expand Down
1 change: 1 addition & 0 deletions widgets/hits.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function hits({container = null, templates = {}, hitsPerPage = 20}) {
React.render(
<Hits
hits={results.hits}
results={results}
helper={helper}
noResultsTemplate={templates.empty}
hitTemplate={templates.hit}
Expand Down

0 comments on commit 544ff5c

Please sign in to comment.