haardik | LearnWeb3
haardik | LearnWeb3
Explore posts from servers
TTCTheo's Typesafe Cult
Created by haardik | LearnWeb3 on 1/24/2023 in #questions
Refetching tRPC query after mutation from a child
for those who might stumble upon this later, I did something like this: In NotificationItem (the child)
const utils = trpc.useContext();
const markReadMutation = trpc.notifications.markRead.useMutation({
onSuccess: () => utils.notifications.unread.refetch()
})
const utils = trpc.useContext();
const markReadMutation = trpc.notifications.markRead.useMutation({
onSuccess: () => utils.notifications.unread.refetch()
})
7 replies
TTCTheo's Typesafe Cult
Created by haardik | LearnWeb3 on 1/24/2023 in #questions
Refetching tRPC query after mutation from a child
Oooh thank you! This works beautifully @cje
7 replies
TTCTheo's Typesafe Cult
Created by haardik | LearnWeb3 on 1/24/2023 in #questions
Refetching tRPC query after mutation from a child
One way that works right now is by extracting the refetch function from useQuery and passing it down to each of the children. Then, onSuccess of the mutation, I can call refetch This works, but I wonder if there's a better way?
7 replies