) => {
const q = event.target.value;
if (q.length < 3) {
this.clearResults(q);
return;
}
this.setState({
term: q,
});
this.props.search.search(event.target.value).then(res => {
this.setResults(res, q);
});
};
render() {
const results: SearchResult[] = this.state.results.map(res => ({
item: this.props.getItemById(res.id),
score: res.score,
}));
results.sort(
(a, b) =>
a.item.depth > b.item.depth ? 1 : a.item.depth < b.item.depth ? -1 : b.score - a.score,
);
return (
{results.length > 0 && (
{results.map(res => (
))}
)}
);
}
}