From 7df7469b783a1577bebff0e92816eab805288d5b Mon Sep 17 00:00:00 2001 From: caadiq Date: Tue, 6 Jan 2026 12:22:10 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9D=BC=EC=A0=95=20=EA=B4=80=EB=A6=AC=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=20=EB=B3=B5=EC=9B=90=20-=20React=20StrictMod?= =?UTF-8?q?e=20=EC=9D=B4=EC=A4=91=20=EB=A7=88=EC=9A=B4=ED=8A=B8=20?= =?UTF-8?q?=EB=AC=B8=EC=A0=9C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - useRef로 상태 복원 로직 한 번만 실행되도록 보장 - 두 번째 마운트에서 플래그/상태 삭제 방지 --- frontend/src/pages/pc/admin/AdminSchedule.jsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/frontend/src/pages/pc/admin/AdminSchedule.jsx b/frontend/src/pages/pc/admin/AdminSchedule.jsx index 20c213d..820f6b9 100644 --- a/frontend/src/pages/pc/admin/AdminSchedule.jsx +++ b/frontend/src/pages/pc/admin/AdminSchedule.jsx @@ -20,9 +20,17 @@ function AdminSchedule() { return kstDate.toISOString().split('T')[0]; }; - // sessionStorage에서 저장된 상태 복원 + // sessionStorage에서 저장된 상태 복원 (한 번만 실행) // 일정 폼에서 돌아올 때만 복원 (fromScheduleForm 플래그 확인) + const stateRestoredRef = useRef(false); const getStoredState = () => { + // 이미 복원 로직이 실행된 경우 다시 실행하지 않음 (StrictMode 이중 마운트 대응) + if (stateRestoredRef.current) { + const stored = sessionStorage.getItem('adminScheduleState'); + return stored ? JSON.parse(stored) : null; + } + stateRestoredRef.current = true; + try { const fromForm = sessionStorage.getItem('fromScheduleForm'); if (fromForm) { @@ -38,6 +46,7 @@ function AdminSchedule() { }; const storedState = getStoredState(); + const [loading, setLoading] = useState(false); const [user, setUser] = useState(null); @@ -517,7 +526,10 @@ function AdminSchedule() {