tRPC not invalidating queries called on RSC
I have a Home Component RSC which fetches the data by trpc and passes it to another client component.
The problem is when I mutate the data in the client component the original data isn't invalidated
My best guess would be because RSC don't get re-rendered .
how can I change my approach
4 Replies
const Home = async () => {
const session = await getServerAuthSession();
const initialVaults = await api.vault.getAllVaults.query();
data being fetched on RSC
The client component
Context now replaced with utils try with utils.
yeah it's with useUtils
variable name is context
How did you get this working? I'm using t3 stack but don't seem to have utils :/
Ah I got it working in the end
import { api } from "@/trpc/react";
And in the create form modal:
queryKey
is constructed dynamically in the parent component and passed to this component via a prop