Skip to content

useInfiniteQuery broken on SSR #1794

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

Closed
klarstrup opened this issue Feb 13, 2021 · 8 comments
Closed

useInfiniteQuery broken on SSR #1794

klarstrup opened this issue Feb 13, 2021 · 8 comments

Comments

@klarstrup
Copy link
Contributor

klarstrup commented Feb 13, 2021

Describe the bug
As of 3.9.0 useInfiniteQuery behaves differently during SSR, only returning the request data at QueryResult.data rather than each paginated page at QueryResult.data.pages. But behaves as documented when rerendered client-side.

To Reproduce
Steps to reproduce the behavior:
Change the current nextjs example to use useInfiniteQuery like so: https://github.com/klarstrup/react-query/commit/c2434e563038a7adf9013b30fc916276c3efda3c

I've also written a shoddy little test to confirm the issue: https://github.com/klarstrup/react-query/commit/4f3b37096b8457e742652abab88d4a7b3732ee95

Expected behavior
I would expect the query hooks to not behave different between server and client.


I would hazard a guess that this is fallout from #1775

@boschni
Copy link
Collaborator

boschni commented Feb 13, 2021

Does version 3.9.3 fix your issue?

@klarstrup
Copy link
Contributor Author

Yeah! That works perfectly - cheers

@klarstrup klarstrup reopened this Feb 14, 2021
@klarstrup
Copy link
Contributor Author

Brainfart on my end. The above reproductions still don't work as of 3.9.6

@vipinnair22
Copy link

I'm seeing similar issue where data is not added in pages property and is returned like a response for useQuery.

@boschni
Copy link
Collaborator

boschni commented Feb 15, 2021

This seems to work: 2bcc893

Are you using prefetchInfiniteQuery instead of prefetchQuery?

@klarstrup
Copy link
Contributor Author

Oh I guess I did use the wrong prefetch method in my test up there. But what I'm experiencing in my real app is with using Suspense-based SSR via react-ssr-prepass which worked up until 3.9.0, no prefetch methods.

@boschni
Copy link
Collaborator

boschni commented Feb 15, 2021

Added a test for suspense and infinite queries: ff619d0

Are you sure it does not work with 3.9.6?

@klarstrup
Copy link
Contributor Author

That seems to do the trick 😁 Yes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants