State Management · Senior · Question 29 of 75
What does the select option of useQuery give you?
const count = useQuery({ queryKey: ["todos"], queryFn, select: (d) => d.length });- ✓Correct answer: A derived value; the component re-renders only when that value changes
- 2A choice between several
queryFns - 3A list of fields to request from a GraphQL server
Explanation
The cache keeps the full response while each component subscribes to its own projection. Keep the select function stable (define it outside or memoize it) so it isn't re-run on every render.