-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #259 from boostcampwm-2024/fix/something
[FE] 자잘한 버그 수정 & 즐겨찾기 페이지에서 취소 기능 추가
- Loading branch information
Showing
9 changed files
with
83 additions
and
54 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; | ||
import { bookmark, getBookmarkedStocks, unbookmark } from 'service/bookmark'; | ||
|
||
export default function useBookmark() { | ||
const queryClient = useQueryClient(); | ||
|
||
const bookmarkQuery = useQuery( | ||
['bookmark', 'stock'], | ||
() => getBookmarkedStocks(), | ||
{ | ||
staleTime: 1000, | ||
suspense: true, | ||
}, | ||
); | ||
|
||
const like = useMutation((code: string) => bookmark(code), { | ||
onSuccess: () => queryClient.invalidateQueries(['bookmark', 'stock']), | ||
}); | ||
|
||
const unlike = useMutation((code: string) => unbookmark(code), { | ||
onSuccess: () => queryClient.invalidateQueries(['bookmark', 'stock']), | ||
}); | ||
|
||
return { bookmarkQuery, like, unlike }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters