From 5fd41b3bbbdaeb3d6eef160db7ee9b5cf928d7a0 Mon Sep 17 00:00:00 2001 From: NamKyeongMin Date: Sat, 21 Jun 2025 03:34:06 +0900 Subject: [PATCH] =?UTF-8?q?[fix]:=20=EB=82=A0=EC=A7=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20=EB=A6=AC=EB=A1=9C=EB=94=A9=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EC=88=98=EC=A0=95(useRef=EB=A1=9C=20=EB=B3=80=EA=B2=BD)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/generation/Attendance.jsx | 24 ++++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/frontend/src/pages/generation/Attendance.jsx b/frontend/src/pages/generation/Attendance.jsx index 8d6d1ac..32a379f 100644 --- a/frontend/src/pages/generation/Attendance.jsx +++ b/frontend/src/pages/generation/Attendance.jsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from "react"; +import { useEffect, useState, useRef } from "react"; import Header from "../../components/Header"; import InputBlock from "../../components/InputBlock"; import AttendanceWeekInfo from "../../components/AttendanceWeekInfo"; @@ -14,10 +14,7 @@ const Attendance = () => { "not_started", ]); - // 오늘 날짜 비교용 state - const [currentDate, setCurrentDate] = useState( - new Date().toISOString().split("T")[0] - ); + const currentDateRef = useRef(new Date().toISOString().split("T")[0]); const getSubImage = (count) => { switch (count) { @@ -156,8 +153,14 @@ const Attendance = () => { // 매 분마다 현재 날짜를 확인해서 달라졌으면 상태 업데이트 const dateCheckInterval = setInterval(() => { const todayStr = new Date().toISOString().split("T")[0]; - if (todayStr !== currentDate) { - setCurrentDate(todayStr); // 날짜 변경 감지 + if (todayStr !== currentDateRef.current) { + console.log( + "날짜 변경 감지 / 이전:", + currentDateRef.current, + "→ 현재:", + todayStr + ); + currentDateRef.current = todayStr; // 날짜 갱신 fetchTodayAttendance(); // 새로운 날짜 기준으로 다시 가져오기 } }, 60000); // 60초마다 확인 @@ -230,11 +233,12 @@ const Attendance = () => { )}
- {todayStatuses.map((status, idx) => ( + {todayStatuses.map((status, idx) => { + console.log(`렌더링된 이미지 ${idx + 1}:`, getBoomImage(status));
{`attendance-${idx}`} -
- ))} +
; + })}
{attendanceData.map(({ week, classes }) => (