Rule of hooks error
Hello,
I'm discovering T3 Stack and I'm struggling with the react rule of hooks.
I would like to call this query :
When I click on my button
Is there any way to call the query like a mutation ?
Thanks in advance !
7 Replies
you can't call a hook conditionally
that breaks the rules of react
Yeah I see that but then how can I do it ? 😅
easiest solution is to just make the query a mutation
or
use the
enabled
property in react queryOh okay thanks
Dependent Queries | TanStack Query Docs
Dependent (or serial) queries depend on previous ones to finish before they can execute. To achieve this, it's as easy as using the enabled option to tell a query when it is ready to run:
syntax will be a bit different but you get the idea
thanks i'll try this