From 312dc4e0ce47178bbd84b87f5d5c54efdc90d8d0 Mon Sep 17 00:00:00 2001 From: paulcjy Date: Fri, 20 Sep 2024 04:28:29 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=9F=AC=EB=B8=94=EB=A6=AC=20=ED=85=8C?= =?UTF-8?q?=EB=A7=88=EB=8F=84=20useEffect=20=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/LovelyCalendar.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/components/LovelyCalendar.tsx b/components/LovelyCalendar.tsx index 6ed3930..1581c94 100644 --- a/components/LovelyCalendar.tsx +++ b/components/LovelyCalendar.tsx @@ -1,12 +1,13 @@ 'use client' -import { useMemo, useState, useCallback } from 'react' +import { useMemo, useState, useCallback, useEffect } from 'react' import Link from 'next/link' import { ChevronLeft, ChevronRight, Heart } from 'lucide-react' import { BibleData, DayData } from './calendar/types' export const LovelyCalendar = ({ bibleData }: { bibleData: BibleData }) => { const [currentDate, setCurrentDate] = useState(new Date()) - const today = useMemo(() => new Date(), []) + const [calendar, setCalendar] = useState([]) + const [today, setToday] = useState(new Date()) const CALENDAR_TITLE = '주내힘교회 청소년부' const CALENDAR_SUBTITLE = '성경읽기표' @@ -73,10 +74,10 @@ export const LovelyCalendar = ({ bibleData }: { bibleData: BibleData }) => { [bibleData, today] ) - const calendar = useMemo( - () => createCalendar(currentDate), - [currentDate, createCalendar] - ) + useEffect(() => { + const calendar = createCalendar(currentDate) + setCalendar(calendar) + }, [currentDate]) const changeMonth = useCallback((d: number) => { setCurrentDate(