How to query with async/await
I'm trying to initialise my react context store on mount with data coming from trpc.
I'm using the t3 stack right now, and it's not immediately obvious on how to wait for the data to load before setting it in the store..
I'm using zustand and he is a snippet of my code
3 Replies
I take it that you aren't actually supposed to use the query client like that outside of component
So what would be the next prefered method ?
Why would you use zustand when react query already caches data, dedupes requests and has primitives to interact with the data?
I'm not sure if I didn't understand some requirement, but I would do something like this:
I'm actually not sure what is the syntax for some of the code above, so it may not work out of the box
And if you really need to use zustand with react query this way, I think you will need to use mutations
This looks interesting
I haven't really thought about doing it like this
I'll try this