We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7cbb8ff commit bf6fe22Copy full SHA for bf6fe22
frontend/src/hooks/usePages.ts
@@ -1,4 +1,10 @@
1
-import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
+import {
2
+ useQuery,
3
+ useMutation,
4
+ useQueryClient,
5
+ skipToken,
6
+} from "@tanstack/react-query";
7
+
8
import {
9
getPages,
10
createPage,
@@ -7,6 +13,15 @@ import {
13
type PageRequest,
14
} from "@/api/page";
15
16
+export const usePage = (currentPage: number | null) => {
17
+ const { data, isError } = useQuery({
18
+ queryKey: ["page", currentPage],
19
+ queryFn: currentPage ? () => getPage(currentPage) : skipToken,
20
+ });
21
22
+ return { data, isError };
23
+};
24
25
export const usePages = () => {
11
26
const { data, isError } = useQuery({
12
27
queryKey: ["pages"],
0 commit comments