Skip to content

Commit

Permalink
Fix Seneca-CDOT#1420 - site crash when no post found
Browse files Browse the repository at this point in the history
  • Loading branch information
DukeManh committed Feb 14, 2021
1 parent 9c3869d commit 77e83ce
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

0 comments on commit 77e83ce

Please sign in to comment.