Skip to content

"Uncaught TypeError: Illegal invocation" when using useAsync #20

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

Closed
tomshane opened this issue Feb 12, 2019 · 4 comments
Closed

"Uncaught TypeError: Illegal invocation" when using useAsync #20

tomshane opened this issue Feb 12, 2019 · 4 comments

Comments

@tomshane
Copy link

When I'm using useAsync hook instead of the <Async> component, when the parent component (page) gets unmounted, it throws this error:

Uncaught TypeError: Illegal invocation
    at HTMLUnknownElement.callCallback (react-dom.development.js:149)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:199)
    at invokeGuardedCallback (react-dom.development.js:256)
    at safelyCallDestroy (react-dom.development.js:16733)
    at commitUnmount (react-dom.development.js:17070)
    at commitNestedUnmounts (react-dom.development.js:17114)
    at unmountHostComponents (react-dom.development.js:17375)
    at commitDeletion (react-dom.development.js:17427)
    at commitAllHostEffects (react-dom.development.js:18168)
    at HTMLUnknownElement.callCallback (react-dom.development.js:149)
callCallback @ react-dom.development.js:149
invokeGuardedCallbackDev @ react-dom.development.js:199
invokeGuardedCallback @ react-dom.development.js:256
safelyCallDestroy @ react-dom.development.js:16733
commitUnmount @ react-dom.development.js:17070
commitNestedUnmounts @ react-dom.development.js:17114
unmountHostComponents @ react-dom.development.js:17375
commitDeletion @ react-dom.development.js:17427
commitAllHostEffects @ react-dom.development.js:18168
callCallback @ react-dom.development.js:149
invokeGuardedCallbackDev @ react-dom.development.js:199
invokeGuardedCallback @ react-dom.development.js:256
commitRoot @ react-dom.development.js:18392
completeRoot @ react-dom.development.js:19884
performWorkOnRoot @ react-dom.development.js:19813
performWork @ react-dom.development.js:19721
performSyncWork @ react-dom.development.js:19695
interactiveUpdates$1 @ react-dom.development.js:19964
interactiveUpdates @ react-dom.development.js:2169
dispatchInteractiveEvent @ react-dom.development.js:4878

I'm using React 16.8.0 with official hooks API, however this was the case even with the previous alpha.

@ghengeveld
Copy link
Member

Thanks for reporting! Do you have a small example how to reproduce this?

@KaRkY
Copy link

KaRkY commented Feb 12, 2019

Just encountered the same problem.

bug lies in this line. AbortControllers abort method gets called with null context.

If you change this line to this useEffect(() => () => abortController.current.abort(), []) it should work OK.

@ghengeveld
Copy link
Member

Thanks! I'll push a fix soon. There's also a major update (v4) coming up, but I'll patch this bug separately.

@ghengeveld
Copy link
Member

Published in v3.13.3.

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