Add maxResults to Search component

release
Etienne Lemay 2016-07-08 17:05:26 -04:00
parent dba6d60a08
commit 510d4b30fd
1 changed files with 4 additions and 0 deletions

View File

@ -54,6 +54,8 @@ export default class Search extends React.Component {
results = this.index.search(this.tokenize(value)).map((result) =>
result.ref
)
results = results.slice(0, this.props.maxResults)
}
this.props.onSearch(results)
@ -76,8 +78,10 @@ export default class Search extends React.Component {
Search.propTypes = {
onSearch: React.PropTypes.func,
maxResults: React.PropTypes.number,
}
Search.defaultProps = {
onSearch: (() => {}),
maxResults: 75,
}