Skip to content

Commit

Permalink
fix: dynamic pages to return null when document is not found
Browse files Browse the repository at this point in the history
LIIKUNTA-441.

Return null to fix SSR rendering when the getSTaticProps returns with notFound: true.
This is null-checker fix is needed only with fallback: true -option on, 
but should not be needed at all. The fallback: 'blocking' hides the issue 
and makes it all work better.
  • Loading branch information
nikomakela committed Mar 28, 2023
1 parent 967dddd commit 4c0754b
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apps/events-helsinki/src/pages/articles/[...slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ const NextCmsArticle: NextPage<{

const { footerMenu } = useContext(NavigationContext);

// FIXME: Return null to fix SSR rendering for notFound-page.
// This is needed only with fallback: true, but should not be needed at all.
if (!article) return null;

return (
<MatomoWrapper>
<RHHCPage
Expand Down
4 changes: 4 additions & 0 deletions apps/events-helsinki/src/pages/pages/[...slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ const NextCmsPage: NextPage<{
const { footerMenu } = useContext(NavigationContext);
const { t: appTranslation } = useAppEventsTranslation();

// FIXME: Return null to fix SSR rendering for notFound-page.
// This is needed only with fallback: true, but should not be needed at all.
if (!page) return null;

return (
<MatomoWrapper>
<HCRCPage
Expand Down
4 changes: 4 additions & 0 deletions apps/hobbies-helsinki/src/pages/articles/[...slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ const NextCmsArticle: NextPage<{
const { t: appTranslation } = useAppHobbiesTranslation();
const { footerMenu } = useContext(NavigationContext);

// FIXME: Return null to fix SSR rendering for notFound-page.
// This is needed only with fallback: true, but should not be needed at all.
if (!article) return null;

return (
<MatomoWrapper>
<RHHCPage
Expand Down
5 changes: 5 additions & 0 deletions apps/hobbies-helsinki/src/pages/pages/[...slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ const NextCmsPage: NextPage<{
} = useConfig();
const { footerMenu } = useContext(NavigationContext);
const { t: appTranslation } = useAppHobbiesTranslation();

// FIXME: Return null to fix SSR rendering for notFound-page.
// This is needed only with fallback: true, but should not be needed at all.
if (!page) return null;

return (
<MatomoWrapper>
<HCRCPage
Expand Down
4 changes: 4 additions & 0 deletions apps/sports-helsinki/src/pages/articles/[...slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ const NextCmsArticle: NextPage<{
const { t: appTranslation } = useAppSportsTranslation();
const { footerMenu } = useContext(NavigationContext);

// FIXME: Return null to fix SSR rendering for notFound-page.
// This is needed only with fallback: true, but should not be needed at all.
if (!article) return null;

return (
<MatomoWrapper>
<RHHCPage
Expand Down
5 changes: 5 additions & 0 deletions apps/sports-helsinki/src/pages/pages/[...slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ const NextCmsPage: NextPage<{
} = useConfig();
const { footerMenu } = useContext(NavigationContext);
const { t: appTranslation } = useAppSportsTranslation();

// FIXME: Return null to fix SSR rendering for notFound-page.
// This is needed only with fallback: true, but should not be needed at all.
if (!page) return null;

return (
<MatomoWrapper>
<HCRCPage
Expand Down

0 comments on commit 4c0754b

Please sign in to comment.