feat: Add staleTime

This commit is contained in:
jhynsoo 2023-11-13 23:55:30 +09:00
parent 4f9d9269f5
commit 36f3a6cd18
5 changed files with 9 additions and 17 deletions

View File

@ -9,6 +9,7 @@ const queryClient = new QueryClient({
defaultOptions: {
queries: {
suspense: true,
refetchOnWindowFocus: false,
},
},
});

View File

@ -8,7 +8,7 @@ const getBrands = async () => {
export const useBrands = () => {
const data = useQuery('brands', () => getBrands(), {
suspense: true,
staleTime: 1000 * 60 * 60 * 24,
});
return data;
@ -21,7 +21,7 @@ const getBrand = async (id) => {
export const useBrand = (id) => {
const data = useQuery(['products', id], () => getBrand(id), {
suspense: true,
staleTime: 1000 * 60 * 60 * 24,
});
return data;
@ -33,9 +33,7 @@ const getBrandProduct = async (id) => {
};
export const useBrandProduct = (id) => {
const data = useQuery(['brandproduct', id], () => getBrandProduct(id), {
suspense: true,
});
const data = useQuery(['brandproduct', id], () => getBrandProduct(id));
return data;
};

View File

@ -8,7 +8,7 @@ const getGraph = async (id) => {
export const useGraph = (id) => {
const data = useQuery(['post', id], () => getGraph(id), {
suspense: true,
staleTime: 1000 * 60 * 60 * 24,
});
return data;

View File

@ -11,9 +11,7 @@ const getPosts = async ({ my, page }) => {
};
export const usePosts = ({ my, page }) => {
const data = useQuery(['post', my, page], () => getPosts({ my, page }), {
suspense: true,
});
const data = useQuery(['post', my, page], () => getPosts({ my, page }));
return data;
};
@ -24,9 +22,7 @@ const getPost = async (id) => {
};
export const usePost = (id) => {
const data = useQuery(['post', id], () => getPost(id), {
suspense: true,
});
const data = useQuery(['post', id], () => getPost(id));
return data;
};

View File

@ -8,7 +8,7 @@ const getProducts = async () => {
export const useProducts = () => {
const data = useQuery('products', () => getProducts(), {
suspense: true,
staleTime: 1000 * 60 * 60 * 24,
});
return data;
@ -21,7 +21,7 @@ const getProduct = async (id) => {
export const useProduct = (id) => {
const data = useQuery(['product', id], () => getProduct(id), {
suspense: true,
staleTime: 1000 * 60 * 60 * 24,
});
return data;
@ -37,9 +37,6 @@ export const useProductPost = ({ id, page }) => {
const data = useQuery(
['productpost', id],
() => getProductPost({ id, page }),
{
suspense: true,
}
);
return data;