From 1d1f9d0684b07f1339481b4ebb7ca25509d6f8c9 Mon Sep 17 00:00:00 2001 From: LimDong Date: Mon, 24 Jun 2024 14:21:00 +0900 Subject: [PATCH] =?UTF-8?q?[#181]=20Fix:=20=EB=B9=8C=EB=93=9C=20=EC=97=90?= =?UTF-8?q?=EB=9F=AC=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/growth/[growthId]/content/index.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pages/growth/[growthId]/content/index.tsx b/pages/growth/[growthId]/content/index.tsx index fd6f093..c4f8cac 100644 --- a/pages/growth/[growthId]/content/index.tsx +++ b/pages/growth/[growthId]/content/index.tsx @@ -4,10 +4,10 @@ import { GrowthDetailsContent } from '@/types/growth/details'; interface ContentProps { category: string; - content: GrowthDetailsContent; + content?: GrowthDetailsContent; } -export default function Content({ category, content }: ContentProps) { +export default function Content({ category, content = {} as GrowthDetailsContent }: ContentProps) { const getTitleColor = (category: string) => { switch (category) { case '간식': @@ -32,13 +32,16 @@ export default function Content({ category, content }: ContentProps) { return styles.foodContent; } }; - const getTitleAndContent = () => { + const getTitleAndContent = (): { title: string; content: React.ReactNode } => { switch (category) { case '간식': return { title: '간식', content: content.snack }; case '이상 증상': return { title: '이상 증상', content: content.abnormalSymptom }; default: + if (!content.food) { + throw new Error('content.food 속성이 정의되지 않았습니다.'); + } return { title: '사료', content: content.food }; } };