Skip to content

Commit bbe8e9a

Browse files
committed
chore: make isPrefetch a private parameter
1 parent 7e6db78 commit bbe8e9a

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

packages/toolkit/src/query/core/buildInitiate.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ type StartQueryActionCreator<
5858
> = (
5959
arg: QueryArgFrom<D>,
6060
options?: StartQueryActionCreatorOptions,
61-
isPrefetch?: boolean
6261
) => ThunkAction<QueryActionCreatorResult<D>, any, any, UnknownAction>
6362

6463
export type QueryActionCreatorResult<
@@ -302,8 +301,8 @@ You must add the middleware for RTK-Query to function correctly!`,
302301
forceRefetch,
303302
subscriptionOptions,
304303
[forceQueryFnSymbol]: forceQueryFn,
305-
} = {},
306-
isPrefetch
304+
...rest
305+
} = {}
307306
) =>
308307
(dispatch, getState) => {
309308
const queryCacheKey = serializeQueryArgs({
@@ -321,7 +320,7 @@ You must add the middleware for RTK-Query to function correctly!`,
321320
originalArgs: arg,
322321
queryCacheKey,
323322
[forceQueryFnSymbol]: forceQueryFn,
324-
isPrefetch
323+
...rest
325324
})
326325
const selector = (
327326
api.endpoints[endpointName] as ApiEndpointQuery<any, any>

packages/toolkit/src/query/core/buildThunks.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -610,12 +610,13 @@ In the case of an unhandled error, no tags will be "provided" or "invalidated".`
610610
const force = hasTheForce(options) && options.force
611611
const maxAge = hasMaxAge(options) && options.ifOlderThan
612612

613-
const queryAction = (force: boolean = true) =>
614-
(api.endpoints[endpointName] as ApiEndpointQuery<any, any>).initiate(
613+
const queryAction = (force: boolean = true) =>{
614+
const options = { forceRefetch: force, isPrefetch: true }
615+
return (api.endpoints[endpointName] as ApiEndpointQuery<any, any>).initiate(
615616
arg,
616-
{ forceRefetch: force },
617-
true
618-
)
617+
options
618+
)
619+
}
619620
const latestStateValue = (
620621
api.endpoints[endpointName] as ApiEndpointQuery<any, any>
621622
).select(arg)(getState())

0 commit comments

Comments
 (0)