Cache
This commit is contained in:
@@ -1,16 +1,23 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import * as api from "../service/AboutService";
|
||||
import { useParams } from "next/navigation";
|
||||
import * as api from "../service/AboutService";
|
||||
import { setPersistedAboutData } from "@/lib/helpers/themeCache";
|
||||
|
||||
export const useGetAbout = () => {
|
||||
const { name } = useParams<{ name: string }>();
|
||||
return useQuery({
|
||||
queryKey: ["about", name],
|
||||
queryFn: () => api.getAbout(name),
|
||||
queryFn: async () => {
|
||||
const data = await api.getAbout(name);
|
||||
setPersistedAboutData(name, data);
|
||||
return data;
|
||||
},
|
||||
enabled: !!name,
|
||||
retry: false,
|
||||
staleTime: 5 * 60_000,
|
||||
staleTime: 60 * 60_000,
|
||||
gcTime: 24 * 60 * 60_000,
|
||||
refetchOnMount: false,
|
||||
refetchOnWindowFocus: false,
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user