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

Doesn't work in basic react-app #10

Closed
BuonOmo opened this issue Jan 23, 2018 · 2 comments
Closed

Doesn't work in basic react-app #10

BuonOmo opened this issue Jan 23, 2018 · 2 comments

Comments

@BuonOmo
Copy link

BuonOmo commented Jan 23, 2018

I've used create-react-app (which means Webpack under the hook!), and when I tried to play with this polyfill I had the following error:

Line 77:  'AbortController' is not defined  no-undef

I added some console.log in the abortcontroller script and saw nothing...

@mo
Copy link
Owner

mo commented Jan 25, 2018

It works but the eslint config in create-react-app creates a compile error whenever you access a global variable which is not whitelisted in the eslint "browser" environment and AbortController is so new that it is not included there yet.

You can workaround the issue by adding "const AbortController = window.AbortController;" in each file where you use AbortController. This will not be necessary once the npm "globals" package lists AbortController in the browser environment (which will probably happen reasonably soon, one way or the other).

I've created a boilerplate repo that shows "create-react-app + unfetch + abortcontroller-polyfill", see:
https://github.com/mo/abortcontroller-polyfill-create-react-app-example

@asimmakhmudov
Copy link

Thanks!

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

3 participants