From 35fdc7af1478aedacdb10276394dad4248b20e46 Mon Sep 17 00:00:00 2001 From: DrMint Date: Mon, 5 Dec 2022 03:47:21 +0100 Subject: [PATCH] Removed one more useMemo --- src/pages/chronicles/[slug]/index.tsx | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/pages/chronicles/[slug]/index.tsx b/src/pages/chronicles/[slug]/index.tsx index b3e3c80..f57cd89 100644 --- a/src/pages/chronicles/[slug]/index.tsx +++ b/src/pages/chronicles/[slug]/index.tsx @@ -43,14 +43,10 @@ const Chronicle = ({ chronicle, chapters, ...otherProps }: Props): JSX.Element = ), }); - const primaryContent = useMemo< - NonNullable["data"][number]["attributes"] - >( - () => - filterHasAttributes(chronicle.contents?.data, ["attributes.translations"] as const)[0] - ?.attributes, - [chronicle.contents?.data] - ); + const primaryContent = chronicle.contents + ? filterHasAttributes(chronicle.contents.data, ["attributes.translations"] as const)[0] + ?.attributes + : undefined; const [selectedContentTranslation, ContentLanguageSwitcher, ContentLanguageSwitcherProps] = useSmartLanguage({