Skip to content

Commit 174c05a

Browse files
msutkowskiphryneas
andauthored
Add reducerPath to extractRehydrationInfo (#1645)
Co-authored-by: Lenz Weber <mail@lenzw.de>
1 parent 2630ac9 commit 174c05a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

packages/toolkit/src/query/createApi.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,12 @@ export interface CreateApiOptions<
153153
refetchOnReconnect?: boolean
154154

155155
extractRehydrationInfo?: (
156-
action: AnyAction
156+
action: AnyAction,
157+
{
158+
reducerPath,
159+
}: {
160+
reducerPath: ReducerPath
161+
}
157162
) =>
158163
| undefined
159164
| CombinedState<
@@ -200,9 +205,10 @@ export function buildCreateApi<Modules extends [Module<any>, ...Module<any>[]]>(
200205
...modules: Modules
201206
): CreateApi<Modules[number]['name']> {
202207
return function baseCreateApi(options) {
203-
const extractRehydrationInfo = defaultMemoize(
204-
options.extractRehydrationInfo ??
205-
((() => {}) as (a: AnyAction) => undefined)
208+
const extractRehydrationInfo = defaultMemoize((action: AnyAction) =>
209+
options.extractRehydrationInfo?.(action, {
210+
reducerPath: (options.reducerPath ?? 'api') as any,
211+
})
206212
)
207213
const optionsWithDefaults = {
208214
reducerPath: 'api',

0 commit comments

Comments
 (0)