1
0
Fork 0

fix(docsearch): make sure there are search suggestions before showing them

This commit is contained in:
François Chalifour 2020-04-10 10:54:26 +02:00
parent 3c5b4fff8f
commit ef3566f5b7

View file

@ -20,7 +20,8 @@ interface NoResultsScreenProps
}
export function NoResultsScreen(props: NoResultsScreenProps) {
const searchSuggestions: string[] = props.state.context.searchSuggestions;
const searchSuggestions: string[] | undefined =
props.state.context.searchSuggestions;
return (
<div className="DocSearch-NoResults">
@ -31,7 +32,7 @@ export function NoResultsScreen(props: NoResultsScreenProps) {
No results for "<strong>{props.state.query}</strong>".
</p>
{searchSuggestions.length > 0 && (
{searchSuggestions && searchSuggestions.length > 0 && (
<p>
Try searching for{' '}
{searchSuggestions.slice(0, 3).reduce<React.ReactNode[]>(