Browsers will soon support an API to allow developers to abort fetches. Aborting requests within React Request currently is not currently supported, but it is on the project roadmap.
For more, refer to this GitHub issue.
The <Fetch/>
component will "pseudo-abort" requests. With a faux-abort, the actual HTTP request
will not be aborted, but there are situations when the response will be ignored:
- When the component unmounts
- When a new request is initiated while an existing request is already in flight
In these situations, onResponse
will be called with an error that has a name
equal
to AbortError
.
You may be tempted to use the signal
prop of <Fetch/>
to abort requests, but this
may not work as well as you would like it to. The <Fetch/>
component will make a new
request anytime a new request key is generated from the props that
you pass in.
This means that you would need to create a new AbortController
any time that there is
a new request key. Although this may work for limited use cases, it does not scale well,
so we do not recommend it as a general practice.