-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use tanstack query instead nextjs features for static build
- Loading branch information
1 parent
3b43776
commit 21e8ef0
Showing
13 changed files
with
138 additions
and
87 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"use client"; | ||
|
||
import { useMutation, useQueryClient, useSuspenseQuery } from "@tanstack/react-query"; | ||
import { getComments, postComment } from "./api"; | ||
|
||
export const useCommentList = (slug: string) => | ||
useSuspenseQuery({ | ||
queryKey: ["commentList", slug], | ||
queryFn: () => getComments(slug), | ||
}); | ||
|
||
export const usePostComment = (slug: string) => { | ||
const queryClient = useQueryClient(); | ||
return useMutation({ | ||
mutationFn: (comment: Parameters<typeof postComment>[0]) => postComment(comment), | ||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ["commentList", slug] }), | ||
}); | ||
}; |
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,3 +1,2 @@ | ||
export * from "./comment/api"; | ||
export * from "./comment/types"; | ||
export * from "./instance"; |
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,23 @@ | ||
"use client"; | ||
|
||
import httpClient, { HTTPClient } from "#utils/httpClient"; | ||
|
||
export const request: HTTPClient<unknown> = httpClient({ | ||
baseUrl: process.env.NEXT_PUBLIC_API_URL, | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
credentials: "include", | ||
cache: "no-store", | ||
interceptors: { | ||
async response(response) { | ||
try { | ||
return await response.json(); | ||
} catch { | ||
// eslint-disable-next-line no-console | ||
console.error("Failed to parse response body as JSON."); | ||
return null; | ||
} | ||
}, | ||
}, | ||
}); |
File renamed without changes.
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 |
---|---|---|
|
@@ -59,6 +59,7 @@ | |
"sonarsource", | ||
"Svgwr", | ||
"tailwindcss", | ||
"tanstack", | ||
"tistory", | ||
"travisci", | ||
"treeshake", | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.