Skip to content

Commit

Permalink
generalize skiptoken-specific logic
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas committed Sep 21, 2021
1 parent 9035585 commit 63fe01d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/toolkit/src/query/react/useSerializedStableValue.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { useEffect, useRef, useMemo } from 'react'
import type { SerializeQueryArgs } from '@reduxjs/toolkit/dist/query/defaultSerializeQueryArgs'
import type { EndpointDefinition } from '@reduxjs/toolkit/dist/query/endpointDefinitions'
import { skipToken } from '@reduxjs/toolkit/query'

export function useStableQueryArgs<T>(
queryArgs: T | typeof skipToken,
queryArgs: T,
serialize: SerializeQueryArgs<any>,
endpointDefinition: EndpointDefinition<any, any, any, any>,
endpointName: string
Expand All @@ -13,9 +12,9 @@ export function useStableQueryArgs<T>(
() => ({
queryArgs,
serialized:
queryArgs === skipToken
? skipToken
: serialize({ queryArgs, endpointDefinition, endpointName }),
typeof queryArgs == 'object'
? serialize({ queryArgs, endpointDefinition, endpointName })
: queryArgs,
}),
[queryArgs, serialize, endpointDefinition, endpointName]
)
Expand Down

0 comments on commit 63fe01d

Please sign in to comment.