SSR set initialData for Tanstack Query (useQuery) isn't working
Am I doing something wrong because useQuery initialData on server is not being set from route state data resulting in a flicker of UI / hydration errors.
If I only use the state data all is good however I can't do optimistic updates via queryClient API used by useQuery/useMutation .
2 Replies
ambitious-aqua•7mo ago
have you checked this repo? https://stackblitz.com/github/tanstack/router/tree/main/examples/react/start-basic-react-query?embed=1&theme=dark&preset=node&file=app/routes/__root.tsx
StackBlitz
Router Start Basic React Query Example - StackBlitz
Run official live example code for Router Start Basic React Query, created by Tanstack on StackBlitz
optimistic-goldOP•7mo ago
@jarvissa Oh nice, I see queryClient is passed in to createTanStackRouter and then accessed via context, I will look more at that repo.
I did suspect I was maybe using tanstack query wrong.
Thanks for quick response ❤️