React · Senior · Question 49 of 75

What does TanStack Query give you compared to loading data in useEffect with useState?

Explanation

Hand-rolled loading in an effect quickly accumulates problems: response races, no cache (refetching on every mount), duplicates from several components, manual retries and error handling, desync with the server. The library solves this declaratively via keys.

Further reading

Problem with a question

React · Senior · question 49

Test yourself

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

Take this quiz