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