Skip to content

Commit

Permalink
fix: useGetUserInfo 버그 수정 #430
Browse files Browse the repository at this point in the history
  • Loading branch information
novice0840 committed Dec 25, 2024
1 parent ea3a9b7 commit 34de423
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions frontend/src/hooks/useGetUserInfo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useQuery } from '@tanstack/react-query';
import { useEffect } from 'react';
import { useParams, useNavigate } from 'react-router-dom';

import { getUserInfo } from '@/apis/room';
Expand All @@ -16,9 +17,11 @@ const useGetUserInfo = (): RoomAndMember => {
staleTime: USER_INFO_STALE_TIME,
});

if (Number(roomId) !== data?.roomId) {
navigate('/', { replace: true });
}
useEffect(() => {
if (roomId && data?.roomId && Number(roomId) !== data?.roomId) {
navigate('/', { replace: true });
}
}, []);

return {
roomId: data?.roomId || 0,
Expand Down

0 comments on commit 34de423

Please sign in to comment.