Execute Query on Button Click #2160
-
Hello, i have a Use Case where i need to run a query on a button click then wait for the result.
This will throw an error that: Uncaught (in promise) Error: use* functions may only be called during the What is the recommended way to execute a Query on demand? QUICK UPDATE: so i found a workaround or intended implementation
Pause the query by default and execute when needed. best regards, |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
That pattern is lined out here if you want to wait for it in the preview you are better off using the |
Beta Was this translation helpful? Give feedback.
-
I think the update i did in the question is the Vue approach to your answer, my problem with that one is , that i cant change the variables with the .executeQuery method, or i just dont see it how. |
Beta Was this translation helpful? Give feedback.
-
i leave my solution here as reference for some one with similar issues, still not happy with it , feels quit clunky.
|
Beta Was this translation helpful? Give feedback.
That pattern is lined out here if you want to wait for it in the preview you are better off using the
client
by means ofuseClient
and doing.query(variablesQuery, variables).toPromise()
. Generally in React using the rerender pattern will provide you with more benefits 😅