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

Avoid stale state updates #240

Closed
jackfranklin opened this issue May 23, 2019 · 2 comments · Fixed by #243
Closed

Avoid stale state updates #240

jackfranklin opened this issue May 23, 2019 · 2 comments · Fixed by #243
Assignees
Labels
bug 🐛 Oh no! A bug or unintented behaviour.

Comments

@jackfranklin
Copy link

I think that useQuery needs to track if it's been unmounted to avoid stale updates.

We're seeing:

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 sub

And I think it's coming from useQuery. I think the setState calls need to be conditional based on some variable that we toggle from true to false when the component gets updated.

Much like this usePromise example: https://gist.github.com/mjackson/05c7749430d0ec87b66612733805bad6.

Happy to make the PR if you're happy with this proposal?

@andyrichardson andyrichardson added the bug 🐛 Oh no! A bug or unintented behaviour. label May 29, 2019
@andyrichardson
Copy link
Contributor

This should be easily doable using a ref on mount/unmount.

@kitten
Copy link
Member

kitten commented Jun 4, 2019

#256 will additionally ensure that we don't regress on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Oh no! A bug or unintented behaviour.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants