-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Warning: Can't perform a React state update on an unmounted component #1515
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
Comments
sounds like it might be an issue with the current usage of if that doesn't help, we are in the midst of a rewrite, so after this PR is merged that lifecycle method won't be used at all anymore: |
I am using Ok, I will try updating to the |
ok yeah, lemme know! that should be the most progressive path. if that doesn’t work, graphiql 0.x.y versions seem to work best with react 15 |
I tried |
@sashahavia yeah it's all still there: our bad, we should have removed this a while ago. I think in react 16 at some minor version along the way they introduced it. don't usually see this because i don't test with any examples that programatically mount/unmount, GraphiQL is usually the root component in all of our examples! if you fork master branch, you could remove the entire |
this is why the upgrade to react 16 was still in alpha... I knew there'd be issues like this! thanks so much for raising it. I think I'll just make another quick alpha release to fix this before we merge the rewrite |
If you can make another alpha release to fix that that would be great |
@sashahavia i'm still having trouble reproducing the issue, can you provide the steps to produce this bug? perhaps you can document the bug by forking this codesandbox? |
The error happens only when you introduce
|
when you |
Here's a demo : seems to be working ok with a basic so possibly your |
Yes, when I do It only happens when I actually call my redux action to get all endpoints. My action makes an axios request |
Not sure if this helps but here is the full stack trace of the warning
|
hmm, trying to emulate what may be happening and I still don't quite see it - maybe it's re-mounting because of multiple incoming props changes, which would invoke https://codesandbox.io/s/graphiql-js-next-example-qsh7h?file=/src/index.js i have an idea for a quick potential hack though, but I cannot test it because I cannot reproduce this. try this beneath where you import GraphiQL.prototype.componentWillUnmount = undefined; (when i try that it runs fine) I think maybe this indeed is the culprit as suspected, and I could remove the method and re-release without being able to test myself, but this would allow you to test much more quickly |
@sashahavia did you have any luck with that? |
Just want to chase down this bug as it seems to be the only bug stopping us from our stable release for 1.0.0, and then merge a bunch of breaking changes we have waiting. I don't think I'll be able to reproduce this bug it seems like it's timing related, so that line above is what I suspect will prove that we just need to remove that entire lifecycle method |
Looks like |
Great! ok, i'll cut an alpha release today for you to try out. Didn't want to remove that functionality unless it fixed this issue. Thanks a bunch for helping me track it down! |
hmm, looks like this fix will break more functionality than I had thought, particularly with persisting ui state. this is the only place many of these values are set. is that temporary fix O.K. until I can spend some more time on this and cut another alpha later this week? |
No worries. I can wait. It doesn't break the functionality for me, it is just a warning. And by the way I was thinking is it possible to add support for canceling all requests. I think that's what actually breaking. I am using axios in my fetcher and it would be nice if
And then in
And for the fetch request we can use
When I look at the network tab I can see multiple requests being fired at the same time by fetcher function, it would be nice to cancel requests when unMounting since the user can move away from the page before requests are finished |
cancellable operation HTTP requests and WSS subscriptions sound fantastic. this could be added to the default fetcher in the rewrite we are about to merge that will replace a lot of this. the breaking changes from removing also worth noting these changes will all be discarded for the 2.0.0 rewrite, as we are changing how we persist state. if you think the cancellable requests solve it, can you get it working without setting a fetcher should not be making multiple requests each time a request is fired, that sounds like an implementation issue. try here: https://graphiql-test.netlify.app/ |
In my case multiple requests happen because I am using it within Redux form.
|
thank you! very helpful to know |
for a contributor, steps to fix this bug while not breaking features are:
|
@sashahavia we released another alpha today that should take care of this, by avoiding fetch requests during re-renders. let me know if that helps! if not, we will try the other fix as well. |
@acao I didn't have a chance to test it this week. Will try to test it first thing Monday. |
I can confirm that You can add a resolution in your "resolutions": {
"graphql-language-service-interface": "2.4.0-alpha.8"
} |
@zoontek Getting these errors now
|
i can't seem to reproduce this bug with our webpack example in master (see webpack config and babel config) so i will go ahead and publish again from master. |
@sashahavia is this still an issue with the latest alpha.13 release? |
@acao Unfortunately, I am still seeing the error
|
@sashahavia ok! the PR that we thought might fix it had that same error, but I think we had just reproduced it in a different context. gonnna try this other PR, #1544. thanks for helping with this! |
@sashahavia apologies this closed automatically. do you want to see if the 1.0.0 release resolves all of these issues for you? |
@acao I have updated to
|
but we got rid of i'll work on a reproduction of this for tomorrow. 2.0.0 redesign and plugin api on hold! need to get 1.0.x right |
are you using |
@acao We are suing React hooks and I don't have unmount hook in any of the components that I am using |
we have several other thinking about it more though... if it is related to the schema fetch, one workaround you might try is fetching the schema manually from elsewhere in the component tree, and passing it to |
@sashahavia let me know how that workaround goes, and |
@acao The workaround I have tried originally and it didn't help. I just tried |
@sashahavia the original case where someone was able to re-produce a similiar error was resolved, so without a way to re-produce the errors, we're kinda stuck. if you can create a codesandbox that re-creates the error then we should be able to help you. @zoontek i see you are subscribing to this issue. are you having a similar issue? |
@acao Hey, sorry it took me so long. Here is the link to sandbox to re-produce the error |
fanatstic, was able to reproduce with this example, thank you! |
now i can't reproduce it again, hahaha! what are the exact steps with this demo? |
@acao type something in Graphiql, add name and click submit. The error sometimes a little delayed. But I could see it both in sandbox console and chrome console tab |
ok got it! i was doing the first two backwards. i also see that the active query goes blank once the typing begins! maybe a few bugs exposed here. thank you |
Hey @acao, I found why the active query goes blank when we start typing, that's because GraphiQL is passed with the
|
@harshithpabbati yes I'm aware, thanks! |
Closing due to inactivity. Feel free to reply if you still need help. |
I am using
GraphiQL
in the form as a textarea field and every time I hit submit and navigate away from the page I get this warningWarning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
in GraphiQL (created by GraphQlTextArea)
Can someone please look into this?
The text was updated successfully, but these errors were encountered: