graphiql: Warning: Can't perform a React state update on an unmounted component
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 warning
Warning: 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?
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 50 (31 by maintainers)
@acao Getting this error when trying to run the app:
@acao I have updated to
1.0.0release and still got this errorNo worries. I can wait. It doesn’t break the functionality for me, it is just a warning. And by the way
GraphiQL.prototype.componentWillUnmount = undefined;- the warning still pops up but not as oftenI 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
GraphiQLcould acceptcancelfunction and then call it incomponentWillUnmountconst source = axios.CancelToken.source();And then in
GraphiQL<GraphiQL ref={c => graphiql = c} fetcher={createFetcher(api)} query={query} onEditQuery={() => updateQuery()} cancel={source.cancel()}>And for the fetch request we can use
cancelfunction can be optional parameter forGraphiQLWhen 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
@harshithpabbati yes I’m aware, thanks!
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
fanatstic, was able to reproduce with this example, thank you!
@acao Hey, sorry it took me so long. Here is the link to sandbox to re-produce the error
https://codesandbox.io/s/goofy-brook-kvren
@acao We are suing React hooks and I don’t have unmount hook in any of the components that I am using
graphiql@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!
@acao
alpha.13compiled successfullyUnfortunately, I am still seeing the error
@acao I didn’t have a chance to test it this week. Will try to test it first thing Monday.
In my case multiple requests happen because I am using it within Redux form.
GraphQlTextAreahasGraphiQLwith fetcher implementation