From 789dad1e3462ba523d5759f2a010033fb3b37a5e Mon Sep 17 00:00:00 2001 From: tolelom <98kimsungmin@naver.com> Date: Sun, 15 Mar 2026 19:06:15 +0900 Subject: [PATCH] =?UTF-8?q?fix:=203=EC=B0=A8=20=EB=A6=AC=EB=B7=B0=20LOW=20?= =?UTF-8?q?=E2=80=94=20useCallback,=20=EC=A4=91=EB=B3=B5=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0,=20=EC=A0=91=EA=B7=BC=EC=84=B1=20=EA=B0=95=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - DownloadSection loadInfo useCallback 래핑 - DownloadAdmin reload 중복 → 단일 load 함수 - LoginPage/RegisterPage 에러 메시지 role="alert" Co-Authored-By: Claude Opus 4.6 (1M context) --- src/components/DownloadSection.jsx | 6 ++-- src/components/admin/DownloadAdmin.jsx | 41 ++++++++++---------------- src/pages/LoginPage.jsx | 2 +- src/pages/RegisterPage.jsx | 2 +- 4 files changed, 20 insertions(+), 31 deletions(-) diff --git a/src/components/DownloadSection.jsx b/src/components/DownloadSection.jsx index f94b75e..598ee8f 100644 --- a/src/components/DownloadSection.jsx +++ b/src/components/DownloadSection.jsx @@ -1,4 +1,4 @@ -import { useState, useEffect } from 'react'; +import { useState, useEffect, useCallback } from 'react'; import { useNavigate } from 'react-router-dom'; import { useAuth } from '../context/useAuth'; import { getDownloadInfo } from '../api/download'; @@ -14,13 +14,13 @@ export default function DownloadSection() { const { user } = useAuth(); const navigate = useNavigate(); - const loadInfo = () => { + const loadInfo = useCallback(() => { setReady(false); setLoadError(false); getDownloadInfo() .then((data) => { setInfo(data); setReady(true); }) .catch(() => { setLoadError(true); setReady(true); }); - }; + }, []); useEffect(() => { loadInfo(); }, []); diff --git a/src/components/admin/DownloadAdmin.jsx b/src/components/admin/DownloadAdmin.jsx index b4073fe..5bf39fb 100644 --- a/src/components/admin/DownloadAdmin.jsx +++ b/src/components/admin/DownloadAdmin.jsx @@ -1,5 +1,5 @@ // TODO: Add tests for CRUD operations (load download info, upload launcher, upload game) -import { useState, useEffect } from 'react'; +import { useState, useEffect, useCallback } from 'react'; import { getDownloadInfo } from '../../api/download'; import UploadForm from './UploadForm'; import './AdminCommon.css'; @@ -9,29 +9,7 @@ export default function DownloadAdmin() { const [loading, setLoading] = useState(true); const [loadError, setLoadError] = useState(''); - useEffect(() => { - getDownloadInfo() - .then((data) => { - setInfo(data); - setLoadError(''); - }) - .catch((err) => { - console.error('다운로드 정보 로드 실패:', err); - setLoadError('배포 정보를 불러올 수 없습니다.'); - }) - .finally(() => setLoading(false)); - }, []); - - if (loading) { - return ( -
-

게임 배포 관리

-

불러오는 중...

-
- ); - } - - const reload = () => { + const load = useCallback(() => { setLoading(true); setLoadError(''); getDownloadInfo() @@ -44,14 +22,25 @@ export default function DownloadAdmin() { setLoadError('배포 정보를 불러올 수 없습니다.'); }) .finally(() => setLoading(false)); - }; + }, []); + + useEffect(() => { load(); }, [load]); + + if (loading) { + return ( +
+

게임 배포 관리

+

불러오는 중...

+
+ ); + } if (loadError) { return (

게임 배포 관리

{loadError}

- +
); } diff --git a/src/pages/LoginPage.jsx b/src/pages/LoginPage.jsx index 209a774..06985a3 100644 --- a/src/pages/LoginPage.jsx +++ b/src/pages/LoginPage.jsx @@ -68,7 +68,7 @@ export default function LoginPage() { {justRegistered &&

회원가입이 완료되었습니다. 로그인해주세요.

} - {error &&

{error}

} + {error &&

{error}

}