Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Cancel the fetch if it has not been completed and props changed #5

Open
EECOLOR opened this issue Mar 8, 2019 · 4 comments
Open

Cancel the fetch if it has not been completed and props changed #5

EECOLOR opened this issue Mar 8, 2019 · 4 comments
Labels
enhancement New feature or request

Comments

@EECOLOR
Copy link

EECOLOR commented Mar 8, 2019

You can read about the AbortController here: https://developer.mozilla.org/en-US/docs/Web/API/AbortController

@quisido
Copy link
Collaborator

quisido commented Apr 12, 2019

That may not always be desirable behavior, so I'm unsure about doing it by default.

This is mostly an issue of how does it know which request to cancel. Functional components do not have instances, so I can't say "cancel this Component's last request."

@quisido quisido added the enhancement New feature or request label Apr 12, 2019
@EECOLOR
Copy link
Author

EECOLOR commented Apr 13, 2019

I explained poorly. By props I meant arguments to useFetch

@EECOLOR
Copy link
Author

EECOLOR commented Apr 13, 2019

Oh wait, I understand what you are saying. I see the problem now. You can probably use hooks to help solve that though.

@capaj
Copy link

capaj commented Aug 5, 2019

@CharlesStover you can useRef to store abort controllers. Maybe take a look at https://github.com/mauricedb/use-abortable-fetch for inspiration.
Heck you could even use that hook under the covers.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants