State Management · Middle · Question 30 of 75
How do you run a query only after another one returned user.id?
- ✓Correct answer: Pass
enabled: !!user?.idto the dependent query - 2Call the second
useQueryinsideif (user) - 3Call
refetch()of the second query in auseEffect
Explanation
While enabled is false the query doesn't run. Calling hooks conditionally breaks the rules of hooks. user.id must also be part of the dependent query's key.