From ef3566f5b76fb816e93043228bb059985fa884ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Chalifour?= Date: Fri, 10 Apr 2020 10:54:26 +0200 Subject: [PATCH] fix(docsearch): make sure there are search suggestions before showing them --- src/NoResultsScreen.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/NoResultsScreen.tsx b/src/NoResultsScreen.tsx index 64689f888..9f5ff16c3 100644 --- a/src/NoResultsScreen.tsx +++ b/src/NoResultsScreen.tsx @@ -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 (
@@ -31,7 +32,7 @@ export function NoResultsScreen(props: NoResultsScreenProps) { No results for "{props.state.query}".

- {searchSuggestions.length > 0 && ( + {searchSuggestions && searchSuggestions.length > 0 && (

Try searching for{' '} {searchSuggestions.slice(0, 3).reduce(