Skip to content

Commit c4b7b8b

Browse files
committed
[fix] 로그인 시 여러번 뜨는 toast 알림 이슈 수정
1 parent 3723a9b commit c4b7b8b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/domains/login/hook/useLoginRedirect.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useAuthStore } from '@/domains/shared/store/auth';
2-
import { useEffect, useState } from 'react';
2+
import { useEffect, useState, useRef } from 'react';
33
import { usePathname, useRouter } from 'next/navigation';
44
import { getCookie, removeCookie } from '@/domains/shared/auth/utils/cookie';
55
import { useToast } from '@/shared/hook/useToast';
@@ -12,6 +12,7 @@ export const useLoginRedirect = () => {
1212

1313
const [loading, setLoading] = useState(true);
1414
const [welcomeModalOpen, setWelcomeModalOpen] = useState(false);
15+
const hasShownToast = useRef(false);
1516

1617
useEffect(() => {
1718
if (!user && loading) {
@@ -39,7 +40,8 @@ export const useLoginRedirect = () => {
3940

4041
if (pathname.startsWith('/login/user/first-user')) {
4142
setWelcomeModalOpen(true);
42-
} else if (pathname.startsWith('/login/user/success')) {
43+
} else if (pathname.startsWith('/login/user/success') && !hasShownToast.current) {
44+
hasShownToast.current = true;
4345
toastSuccess(`${user.nickname}님 \n 로그인 성공 🎉`);
4446
router.replace(preLoginPath);
4547
setTimeout(() => removeCookie('preLoginPath'), 500);

0 commit comments

Comments
 (0)