Hydration error when using useQuery instead of useSuspenseQuery when prefetching
I have a page
and a component
Where the
DataTable
has some logic like
Using a useQuery
in the PostsTable
component results in a Hydration error. Can I prevent this without having to use Suspense? I found using the isPending
flag to be a way simpler solution to rendering the skeleton in a deeply nested component.3 Replies
I'm having the exact same question, ever found a solution for this?
I updated to the latest and I seem to not be getting this anymore. Can anyone confirm?
Nope, not yet unfortunately. Some findings:
- If I delay the SSR after prefetching significantly (e.g. sleeping right after the prefetch for 4s so the prefetch can complete), the error goes away. This basically means, that if the promise is resolved already, it works.
- If I delay the query's output significantly, so the prefetch cannot be done in time, the error goes away.
- Everything else, is very prone to the hydration mismatch. I.e. it happens close to 100% of the time.
Upgrading to the latest for the trpc and react-query packages did not work. As of now, that is:
Edit: This is the case if I use
query.isFetching
btw. I just need to use this, because I also want to change the table's behavior in case of a refetch. But this shouldn't matter for the initial render afaik.