-
Notifications
You must be signed in to change notification settings - Fork 52
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
Avoid setState on unmounted components #97
Comments
Encountered the same problem, @ericclemmons is there any way we could avoid it? Update: |
I'm curious if this is solved in This exists because resolution happens, you attempt to redirect (which should be synchronous and immediate), but the router seems to trigger the redirect in the next event loop/tick/whatever, meaning the component still renders, mounts, etc. and then the redirect happens. I'm all for a fix, but curious if this has been solved with the rewrite first. |
This line could be executed after unmount regardless redirects, as promise is resolved asynchronously. AFAIK, that's why the blog post suggest to cancelling the promise before unmount. Or am I missing something? |
I suppose the only/best way around this is to track if the component is still mounted or not before calling |
So, I'm using react-resolver with react-router for permissions. So, if a user doesn't pass a certain requirement, they're redirected somewhere. This means that I don't really want to put something to the
props
.I just want to avoid errors such as these:
The text was updated successfully, but these errors were encountered: