fix(docsearch): make sure there are search suggestions before showing them
This commit is contained in:
parent
3c5b4fff8f
commit
ef3566f5b7
1 changed files with 3 additions and 2 deletions
|
|
@ -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[]>(
|
||||
|
|
|
|||
Loading…
Reference in a new issue