Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support aborting #16

Open
techniq opened this issue Jun 22, 2018 · 1 comment
Open

Support aborting #16

techniq opened this issue Jun 22, 2018 · 1 comment

Comments

@techniq
Copy link
Owner

techniq commented Jun 22, 2018

Now that fetch supports aborting using AbortController via a signal, it would be nice if we did as well. Currently we track whether the component is mounted and not call setState, but properly cancelling the fetch request would be better, especially since it's considered an anti-pattern

Some details:

It's only supported in recent green browsers (Chrome, Firefox, Edge, Safari (desktop) and not IE, iOS Safari (currently) so we will need to support opting in / polyfiling.

A quick search returned this polyfill, and Netflix's yetch (which you should be able to pass to the fetchFunction prop

Maybe this is an opt-in via cancellable prop, and we continue to track mounted otherwise.

@techniq
Copy link
Owner Author

techniq commented Dec 6, 2018

Hook implementation that might be worth looking at: https://github.com/mauricedb/use-abortable-fetch

Not sure if fetch-mock supports testing aborting, or if this is ultimately just handled by node-fetch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant