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
prefetchInfiniteQuery - Next.js SSR - Error serializing .dehydratedState.queries[0].state.data.pageParams[0]
#1458
Comments
.dehydratedState.queries[0].state.data.pageParams[0]
.dehydratedState.queries[0].state.data.pageParams[0]
Are you using E.g: initialData: {
pages: [ myFirstPage ],
pageParams: [1]
} |
@jorgemasta no, I am using |
It's the same problem as in #1370 |
#1370 was within our control to fix, but this one is definitely more userland. I think we should file an issue upstream with Next about this instead. |
The best workaround for now would be to |
@tannerlinsley But why should react-query return In
|
Yes it should actually. We should probably dig into that. But regardless, it is possible for a pageParam to be undefined for a page, so we should cover this edge case either way :) |
Pretty stale issue here, and I haven't seen any more reports of it since. Closing for now. |
I agree, please consider fixing this. When anyone follows the directions described and shown in official documentation, it results in this crash when using infinite query. And it seems like it would be uncomplicated fix. Doing |
Here's a repro sandbox for good measure: On another note is that after applying the workaround, after going back to the index page from the about page, the scroll seems to stick to the top and the cached data is gone. Is this a side effect? |
I don't think it's a react-query issue. From what i can see it's a nextjs issue so i'm not sure what you need them to fix. Please read the following quote:
|
This is still an issue, after following the docs as they are, this error is what happens. |
I'm having this same issue. Using |
Trying to prefetch Infinite query from Next.js and getting the same error:
My
|
I fixed the issue using superjson It's a slightly better solution, but the drawback is the need for a new dependency |
I have faced same problem, fixed like this:
|
Bumping this issue as we ran into it again. Definitely want to avoid setting the query manually in our case, so if there's a way to define a default |
we currently use The first page is an exception to the rule (we always fetch the first page). For the first page,
In If we change this behaviour to What dehydration does is merely make a reduced js object out of the Tbh, I was surprised that the
into
I think this only works coincidentally, because we ignore the pageParam completely when fetching the first page: Since v4 is around the corner, and the first element in |
## 💡 이슈 resolve #93 ## 🤩 개요 shop 피드 api 연결 및 SSR 추가입니다. ## 🧑💻 작업 사항 - [x] api 코드 및 hook 작성 - [x] shop피드 query string 넣기 - [x] PullToRefresh api 붙이기 - [x] 상품이 없을 경우 UI 추가 및 style 버그 수정 - [x] SSR ## 📖 참고 사항 SSR 이슈입니다. `Nest.js`에서 `pageParams`의 `0번 index값`이 `undefined`로 들어오는 이슈입니다. TanStack/query#1458 ### 무한 스크롤 https://user-images.githubusercontent.com/62797441/192363166-e5244762-5ccb-408c-b43a-3be81abfb838.mov ### Pull To Refresh https://user-images.githubusercontent.com/62797441/192363248-297de6fb-a348-45d0-a2e1-23cae9f048fe.mov ### feed 옵션 클릭 시 새로운 결과 불러오기 및 상품 결과 없을 경우 UI 영상을 보면 엄청 깜박입니다. 백엔드에서 `isEndofPage`로직이 아직 덜 완성되어 계속 `fetchNextPage`가 동작하기 때문입니다. https://user-images.githubusercontent.com/62797441/192363451-3e1dd8f3-7661-4385-855b-993cb903aeb8.mov
Just wanted to report that the issue is still present in Nextjs 12.2.5 + RQ 4.29.1. Hacky workarounds solves the issue. |
we have a fix for this with v5, you can try out the alpha version already: |
I did everything as it is written in the documentation. srr doesn't work anyway
|
can you show this in a codesandbox reproduction please? |
@d90375 well that's just your data ( |
SerializableError: Error serializing .dehydratedState.queries[0].state.data.pageParams[0] returned from getServerSideProps in "/[[...sort]]". Reason: undefined cannot be serialized as JSON. Please use null or omit this value.
The
pageParams
array when usingprefetchInfiniteQuery
is returning[undefined]
, which cannot be serialized by Next.js. It should return a single element array of the page param that was used to prefetch the infinite query (i.e.[0]
).The text was updated successfully, but these errors were encountered: