Jordan (UNCVRD)
How to execute mutation outside of react context?
Hi! I'm slowly converting code over to v10 - looks great! However, I ran in to an issue when using tRPC within my xstate state machine. I need to run a mutation in one of my states, and since this runs outside of react context, Alex had instructed for me to do the following in v9:
1. set the following property on
window
in _app.tsx
2. Then create a helper function:
3. So now I could do the following in my xstate async method:
However this approach no longer works with v10. I was curious as to how I should approach this now? Thank you!
----
EDIT: should I just be creating a duplicate vanilla trpc proxy client with essentially the same configuration now? seems a bit redundant though...would be nice to be able to access my mutations like client.myRouter.create.mutate()
like i can do with my queries client.myRouter.byId.fetch()
Relevant discussions: https://github.com/trpc/trpc/discussions/2926
https://github.com/trpc/trpc/discussions/135118 replies