T
TanStack7mo ago
foreign-sapphire

Next.js useSuspenseQuery error

I am using Next.js app router. And use useSuspenseQuery In the queryFn I called server actiono directly (exported function from "use server"), but that throws an error saying Cannot update a component while rendering other component.... And when I change queryFn to fetch function that works just fine. I just don't know what is happening
3 Replies
national-gold
national-gold7mo ago
don't use server actions in the queryFn I think we have this documented somewhere
foreign-sapphire
foreign-sapphireOP7mo ago
Oh, I see. Also, if I use next.js app router with tanstack query. It introduces inconsistency between server and client cache Which means if I invalidate query key on server, then that doesn't invoke re-fetch on client
national-gold
national-gold7mo ago
How do you invalidate a queryKey on the server?

Did you find this page helpful?