Theo's Typesafe CultTTC
Theo's Typesafe Cult3y ago
6 replies
boney

Refetching tRPC query after mutation from a child

Hey, this might be a pretty noob tRPC question as I'm quite new to the whole tRPC + TanStack Query setup.

I have a component NotificationPanel which uses tRPC to query unread notifications for a given user.

Once it fetches those notifications, it renders multiple NotificationItem elements and passes the notification object to them.

The NotificationItem has a x button which uses tRPC mutate to mark itself READ.

At this point, i would like the parent NotificationPanel component to re-fetch unread notifications for the user, but am not sure how to achieve this.

I tried digging through TanStack Query docs but didn't find much. On Google, most articles are quite outdated and that approach doesn't seem to work well with tRPC's wrapper around TanStack Query.

Any ideas how to achieve this?
Was this page helpful?