Skip to content

Commit

Permalink
fix(docsearch): make sure there are search suggestions before showing…
Browse files Browse the repository at this point in the history
… them
  • Loading branch information
francoischalifour committed Apr 10, 2020
1 parent 3c5b4ff commit ef3566f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/NoResultsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand All @@ -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[]>(
Expand Down

0 comments on commit ef3566f

Please sign in to comment.