prefetchInfinite causing query on initial load

I am prefetching the data in getStaticProps and it fetches on initial load even with staletime set to infinity. https://www.loom.com/share/454e3d2b75fa426d923e119775d1086c
1 Reply
DivMode
DivModeOP2y ago
export async function getStaticProps() {
const ssg = createProxySSGHelpers({
router: appRouter,
ctx: await createContextInner(),
transformer: superjson,
});

await ssg.domain.getAll.prefetchInfinite({
recordsPerPage: 30,
query: "",
sorting: [{
id: "godaddyDomainData.auctionEndTime",
desc: true,
}],
activeAuctions: true,
filters: {
query: {
items: [{ type: "cond", data: {} }],
},
},
});

return {
props: {
trpcState: ssg.dehydrate(),
},
revalidate: 3600,
};
}
export async function getStaticProps() {
const ssg = createProxySSGHelpers({
router: appRouter,
ctx: await createContextInner(),
transformer: superjson,
});

await ssg.domain.getAll.prefetchInfinite({
recordsPerPage: 30,
query: "",
sorting: [{
id: "godaddyDomainData.auctionEndTime",
desc: true,
}],
activeAuctions: true,
filters: {
query: {
items: [{ type: "cond", data: {} }],
},
},
});

return {
props: {
trpcState: ssg.dehydrate(),
},
revalidate: 3600,
};
}
const {
data,
hasNextPage,
fetchNextPage,
isError,
isFetching,
isLoading,
refetch,
} = trpc.domain.getAll.useInfiniteQuery(
{
recordsPerPage: 30,
query: debounced,
sorting,
activeAuctions,
filters,
},
{
getNextPageParam: (lastPage) => {
// @ts-ignore
const totalPages = Math.floor(lastPage.estimatedTotalHits / lastPage.limit);
// @ts-ignore
const actualPage = lastPage.offset / lastPage.limit;
return actualPage < totalPages ? actualPage + 1 : undefined; // By returning undefined if there are no more pages, hasNextPage boolean will be set to false
},
staleTime: Infinity,
cacheTime: Infinity,
keepPreviousData: true,
refetchOnMount: false,
refetchInterval: false,
refetchOnReconnect: false,
refetchOnWindowFocus: false,
},
);
const {
data,
hasNextPage,
fetchNextPage,
isError,
isFetching,
isLoading,
refetch,
} = trpc.domain.getAll.useInfiniteQuery(
{
recordsPerPage: 30,
query: debounced,
sorting,
activeAuctions,
filters,
},
{
getNextPageParam: (lastPage) => {
// @ts-ignore
const totalPages = Math.floor(lastPage.estimatedTotalHits / lastPage.limit);
// @ts-ignore
const actualPage = lastPage.offset / lastPage.limit;
return actualPage < totalPages ? actualPage + 1 : undefined; // By returning undefined if there are no more pages, hasNextPage boolean will be set to false
},
staleTime: Infinity,
cacheTime: Infinity,
keepPreviousData: true,
refetchOnMount: false,
refetchInterval: false,
refetchOnReconnect: false,
refetchOnWindowFocus: false,
},
);
When turning off prefetch it does a double query. Turned off intersection observer and that doesnt seems to be it either.
Want results from more Discord servers?
Add your server