Replies: 1 comment 1 reply
-
I think you see the loader again because you await the prefetching. Try without it: - await queryClient.prefetchQuery({
+ queryClient.prefetchQuery({
queryKey: ['getPosts', category_slug_plural, locale],
queryFn: () =>
getPosts({
category_slug_plural: category_slug_plural,
}),
}) but make sure you opt into hydrating promises to the client as described here: https://tanstack.com/query/v5/docs/framework/react/guides/advanced-ssr#streaming-with-server-components |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a page with multiple posts and everything is working, but I'm noticing a problem when navigating between pages.
The goal here is to have a proper rendering for SEO (using suspense and streaming).
When I see the source code, everything is fine and I have my data on the page. Lazy loading (loading suspense) works fine.
But now when I load this page for the first time, go to another page and come back to this page, the previously loaded data is not displayed and I see the loading suspense again.
I would like to display posts when they are loaded for the first time (without impacting suspense/streaming for SEO), while useQuery is refetching data...
How can I do this?
1st approch
page.tsx
CategoryPostsServer.tsx
CategoryPostsClient.tsx
2nd approch
I tried another approch by using useSuspenseQuery but now I have another issue using my custom fetch API function
Error: Server Functions cannot be called during initial render. This would create a fetch waterfall. Try to use a Server Component to pass data to Client Components instead.
page.tsx
CategoryPostsClient.tsx
getPosts
fetchApi
Beta Was this translation helpful? Give feedback.
All reactions