Skip to content

Commit

Permalink
Fix #1420 - site crash when no post found (#1742)
Browse files Browse the repository at this point in the history
  • Loading branch information
DukeManh authored Feb 15, 2021
1 parent cbf8924 commit 2919f2c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/frontend/next/src/components/SearchResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ const SearchResults = ({ text, filter }: SearchResultProps) => {
}
);
const loading = !data && !error;
// search result is empty when the the posts array on the first page is empty
const isEmpty = data?.[0]?.length === 0;

if (error) {
return (
Expand Down Expand Up @@ -100,7 +102,7 @@ const SearchResults = ({ text, filter }: SearchResultProps) => {

return (
<Container className={classes.searchResults}>
{data && data.length ? (
{!isEmpty ? (
<Timeline pages={data} nextPage={() => setSize(size + 1)} />
) : (
<div className={classes.noResults}>
Expand Down

1 comment on commit 2919f2c

@vercel
Copy link

@vercel vercel bot commented on 2919f2c Feb 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.