#How to control query execution?

2 messages · Page 1 of 1 (latest)

foggy karmaBOT
#

Thanks for posting in #1088161997662724167.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.

  • Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
  • Use search.convex.dev to search Docs, Stack, and Discord all at once.
  • Additionally, you can post your questions in the Convex Community's #1228095053885476985 channel to receive a response from AI.
  • Avoid tagging staff unless specifically instructed.

Thank you!

winged granite
#

I have some code:

export default function LandingPage() {
    const globalStats = useQuery(api.global_kv.getGlobalStats);

    Logger.info("globalStats", globalStats);

   return (...)
}

I want to know if its possible to stop the useQuery from running when the function is rendered. For example if a condition is set like the node env is in dev mode. There are other mutations i would like to do this for, like if my components have an error. But in react you can return before hooks so would that not mean all querys will run even if the data is never used?