-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* TopicCardList 컴포넌트를 이전처럼 활용하도록 한다. 전체보기 및 즐겨찾기는 거의 동일한 형태이며 중복코드가 다량 발생하여 위와 같이 수정한다. * url을 넘겨받음에 따라서 리액트 쿼리 훅, API 요청 로직 또한 하나의 훅으로 재사용한다.
- Loading branch information
1 parent
f2fca6e
commit 645fbf2
Showing
12 changed files
with
142 additions
and
273 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { useSuspenseQuery } from '@tanstack/react-query'; | ||
|
||
import { getTopics } from '../../apis/new'; | ||
|
||
const useGetTopics = (url: string) => { | ||
const { data: topics, refetch } = useSuspenseQuery({ | ||
queryKey: ['topics', url], | ||
queryFn: () => getTopics(url), | ||
}); | ||
|
||
return { topics, refetch }; | ||
}; | ||
|
||
export default useGetTopics; |
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 |
---|---|---|
@@ -1,12 +1,4 @@ | ||
import { TopicCardProps } from '../../types/Topic'; | ||
import { http } from './http'; | ||
|
||
export const getBookmarks = () => | ||
http.get<TopicCardProps[]>('/members/my/bookmarks'); | ||
|
||
export const getNewestTopics = () => | ||
http.get<TopicCardProps[]>('/topics/newest'); | ||
|
||
export const getAllTopics = () => http.get<TopicCardProps[]>('/topics'); | ||
|
||
export const getBestTopics = () => http.get<TopicCardProps[]>('/topics/bests'); | ||
export const getTopics = (url: string) => http.get<TopicCardProps[]>(url); |
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
Oops, something went wrong.