djbalinD
Convex Community2y ago
5 replies
djbalin

useQuery vs one-off query (performance, open connections, etc.)

Hello everyone. I've been thinking about the benefits/tradeoffs of useQuery vs. the imperative/one-off query (https://docs.convex.dev/client/react#one-off-queries) and would love some input.

Basically: what are the performance downsides to using useQuery? Does a useQuery e.g. maintain an open network connection throughout the lifetime of its parent component? Is it better/"safer" to default to one-off queries and only opting in to useQuery when we truly need/want e.g. the reactivity or "undefined" loading state that it provides?

I am asking specifically in the context of a mobile app using tab navigation: When we navigate from screen to screen using the navigation bar, the non-focused screens/components do not unmount but are kept alive in the background. I was therefore considering if absent-mindedly using useQuery in all these screens would/could lead to a lot of unnecessary open connections and/or overhead.

Thank you!
Convex React is the client library enabling your React application to interact
Convex React | Convex Developer Hub
Was this page helpful?