React · Middle · Question 47 of 75
How do you run a query only after user.id is received from another query?
- ✓Correct answer: Pass
enabled: !!user?.idto the second query - 2Call the second
useQueryinside anif (user)condition - 3Call the second query's
refetch()in auseEffect
Explanation
While enabled is false, the query doesn't run (status pending). Calling a hook conditionally breaks the rules of hooks, and a manual refetch in an effect is needless complexity. user.id should be part of the second query's key.