Whats the correct way to wait for `trpc.useQuery` to finish and then update state?

Like the title said, I have a case where I need to press a button 2x to update my state. That happens because useEffect does not wait for useQuery to be finished. Is there a way to sync those two ?
4 Replies
neochrome
neochromeOP3y ago
GitHub
should I put useQuery inside a useEffect and should I store returne...
Still wrapping my head around using this library with modern react hooks patterns. Because data fetching is considered a side effect I've seen this pattern a lot in tutorials and docs. cons...
neochrome
neochromeOP3y ago
found this post, maybe I should do it like explained here?
scatter
scatter3y ago
use the onSuccess callback of useQuery's opts
neochrome
neochromeOP3y ago
you man are a genius thanks
Want results from more Discord servers?
Add your server