State Management · Senior · Question 28 of 75

How do you cancel an in-flight request when a query becomes unused in TanStack Query?

Explanation

queryFn: ({ signal }) => fetch(url, { signal }). The library aborts when the component unmounts before the response, the key changes, or cancelQueries is called. Without signal only result handling is cancelled.

Further reading

Problem with a question

State Management · Senior · question 28

Test yourself

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

Take this quiz