File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import React , { useState } from 'react' ;
2+ import { useQueryClient } from '@tanstack/react-query' ;
23import { useNavigate } from 'react-router-dom' ;
34import styled from '@emotion/styled' ;
45import { colors } from '@styles/theme' ;
@@ -211,6 +212,7 @@ const LimitModalButton = styled.button`
211212
212213const 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 ) ;
You can’t perform that action at this time.
0 commit comments