You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using useInfiniteQuery concurrently with useQuery (on the same page) will lead to an TypeError: Cannot read properties of undefined (reading 'length') exception at
Upon debugging the reason for this is very simple actually, the queryKey generated for both queries will be the same because the methodpathinit are shared between the two.
openapi-react-query version
0.3.0
Description
Using
useInfiniteQuery
concurrently withuseQuery
(on the same page) will lead to anTypeError: Cannot read properties of undefined (reading 'length')
exception atUpon debugging the reason for this is very simple actually, the
queryKey
generated for both queries will be the same because themethod
path
init
are shared between the two.openapi-typescript/packages/openapi-react-query/src/index.ts
Line 220 in 989635a
However the
data
type between the two is different, for useInfiniteQuery the data iswhereas for
useQuery
it's justTData
.So when the
useInfiniteQuery
runs, it'll reuse the same cache as theuseQuery
which results ingetNextPageParams
unable to access thedata.pages
.I believe the solution is for the
queryKey
to be unique for theuseInfiniteQuery
function.Reproduction
One query used in both
useQuery
anduseInfiniteQuery
will trigger exception.Expected result
I can use the same query in both
useQuery
anduseInfiniteQuery
successfully.Extra
The text was updated successfully, but these errors were encountered: