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}

}