T
TanStack3y ago
firm-tan

Enabling abort on unmount

The docs say "By default, queries that unmount or become unused before their promises are resolved are not cancelled". How do I configure that? I'm looking all around the docs for a list of options/configs and am finding nothing except a list of important ones.
4 Replies
firm-tan
firm-tanOP3y ago
It says "However, if you consume the AbortSignal, the Promise will be cancelled" - so does that mean that it will cancel the request if I have { signal } in the query method
exotic-emerald
exotic-emerald3y ago
Yes, but you need to forward the signal to your fetcher https://tanstack.com/query/v4/docs/react/guides/query-cancellation#using-fetch
firm-tan
firm-tanOP3y ago
I do, we have a tool that generates code using ky so I'm going to always forward signal. we always want queries cancelled on unmount
exotic-emerald
exotic-emerald3y ago
That should be enough. Show a codesandbox reproduction?

Did you find this page helpful?