Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfab343a

Browse files
authored
fix: increase default staleTime for paginated data (#11041)
* fix: update default staleTime for paginated data* fix: swap cacheTime for staleTime in app-wide query client* fix: revert cacheTime change* fix: update debug limit* fix: apply staleTime to prefetches* refactor: cleanup code
1 parentf0b4bad commitfab343a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

‎site/src/hooks/usePaginatedQuery.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ export function usePaginatedQuery<
105105
searchParams:outerSearchParams,
106106
queryFn:outerQueryFn,
107107
prefetch=true,
108+
staleTime=60*1000,// One minute
108109
...extraOptions
109110
}=options;
110111

@@ -115,7 +116,8 @@ export function usePaginatedQuery<
115116
constcurrentPage=parsePage(searchParams);
116117
constcurrentPageOffset=(currentPage-1)*limit;
117118

118-
constgetQueryOptionsFromPage=(pageNumber:number)=>{
119+
typeOptions=UseQueryOptions<TQueryFnData,TError,TData,TQueryKey>;
120+
constgetQueryOptionsFromPage=(pageNumber:number):Options=>{
119121
constpageParams:QueryPageParams={
120122
pageNumber,
121123
limit,
@@ -124,13 +126,13 @@ export function usePaginatedQuery<
124126
};
125127

126128
constpayload=queryPayload?.(pageParams)asRuntimePayload<TQueryPayload>;
127-
128129
return{
130+
staleTime,
129131
queryKey:queryKey({ ...pageParams, payload}),
130132
queryFn:(context:QueryFunctionContext<TQueryKey>)=>{
131133
returnouterQueryFn({ ...context, ...pageParams, payload});
132134
},
133-
}asconst;
135+
};
134136
};
135137

136138
// Not using infinite query right now because that requires a fair bit of list
@@ -160,7 +162,6 @@ export function usePaginatedQuery<
160162
}
161163

162164
constoptions=getQueryOptionsFromPage(newPage);
163-
164165
returnqueryClient.prefetchQuery(options);
165166
});
166167

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp