React · Middle · Question 50 of 75

Why does useQuery have a select option?

Explanation

useQuery({ queryKey: ['todos'], queryFn, select: d => d.length }) - the cache stores the full response, while the component gets a derived value and subscribes only to it. For a stable reference, move the select function outside the component or memoize it.

Further reading

Problem with a question

React · Middle · question 50

Test yourself

Take the React · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz