-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
null is passed as pageParam with PersistQueryClientProvider #4309
Comments
please put that code in codesandbox or somewhere were we can run the example, thanks. default serialization uses |
hi, @TkDodo i also got the same problem. Please see this repo for more details. for this information occurs when the application is reloaded. to achieve it, do it like this scroll to last page -> pull to refresh -> reload app (type |
The demo is in JS, but if add types with TypeScript it breaks the types. https://codesandbox.io/s/nifty-frost-8v1kjf?file=/src/App.js Screen.Recording.2022-10-19.at.12.55.37-1.mov |
The issue is that Result of JSON.stringify({ pageParams: [undefined] }) is The same result gives JSON.stringify({ pageParams: [null] }) |
@mrlika you're right about that - I think something similar happens when you try prefetch an infinite query on the server and then try to send it to the client via nextJs, because nextJs also just uses I find it kinda weird that query/packages/query-async-storage-persister/src/index.ts Lines 48 to 49 in 7741a2f
I think having a serializer that omits We could also have a look at how we dehydrate queries and maybe leave out the query/packages/query-core/src/hydration.ts Lines 60 to 66 in 357ec04
Not sure if that would break something though |
The problem is that
there is no real way to serialize this to json and keep the information that there was an entry. superjson supports serializing undefined, so you might just want to use this as a drop-in replacement for JSON.stringify / JSON.parse |
@TkDodo, the issue is that this The solution is to manually make the type |
We've discussed this and there doesn't seem to be a good way that wouldn't break some edge cases where people rely on We have a plan that disallows But, it will have to wait a bit for the next major release. |
Describe the bug
Our code uses
react-native
,useInfiniteQuery
withPersistQueryClientProvider
:According to the type system
pageParam
passed togetMoves
is anumber | undefined
. But when I re-run my appnull
is passed aspageParam
Your minimal, reproducible example
in description
Steps to reproduce
PersistQueryClientProvider
to restore persisted cacheExpected behavior
null
should not be passed aspageParam
according to the typesHow often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
Expo Go on Android
react-query version
4.10.1
TypeScript version
latest
Additional context
No response
The text was updated successfully, but these errors were encountered: