Skip to content

Commit 9e7b50d

Browse files
committed
fix: 친구 요청 후 요청 탭에 바로 반영되도록 수정
1 parent 83edcf0 commit 9e7b50d

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/routers/friendship/AddFriend.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useState } from 'react';
2+
import { useQueryClient } from '@tanstack/react-query';
23
import { useNavigate } from 'react-router-dom';
34
import styled from '@emotion/styled';
45
import { colors } from '@styles/theme';
@@ -211,6 +212,7 @@ const LimitModalButton = styled.button`
211212

212213
const AddFriend = () => {
213214
const navigate = useNavigate();
215+
const queryClient = useQueryClient();
214216
const [searchQuery, setSearchQuery] = useState('');
215217
const effectiveQuery = searchQuery.length >= 2 ? searchQuery : '';
216218
const { data: searchResults, isLoading, error } = useSearchFriends(effectiveQuery);
@@ -240,6 +242,9 @@ const AddFriend = () => {
240242
if (result.status === 200) {
241243
setModalMessage(`${nickname}님에게 친구 요청을 보냈습니다.`);
242244
setShowLimitModal(true);
245+
// 보낸 요청 목록을 최신화하여 요청 화면 진입 시 바로 반영되도록 처리
246+
queryClient.invalidateQueries({ queryKey: ["friendship", "sent-requests"] });
247+
queryClient.refetchQueries({ queryKey: ["friendship", "sent-requests"] });
243248
}
244249
} catch (e) {
245250
const code = e instanceof Error ? e.message : String(e);

0 commit comments

Comments
 (0)