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 happening3 Replies
national-gold•7mo ago
don't use server actions in the queryFn
I think we have this documented somewhere
foreign-sapphireOP•7mo 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•7mo ago
How do you invalidate a queryKey on the server?