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

Memory leak when component unmount before fetch done #54

Closed
Dot-H opened this issue Apr 19, 2020 · 0 comments · Fixed by #55
Closed

Memory leak when component unmount before fetch done #54

Dot-H opened this issue Apr 19, 2020 · 0 comments · Fixed by #55

Comments

@Dot-H
Copy link
Collaborator

Dot-H commented Apr 19, 2020

Hi 👋

Problem

The fetchURL function sets the loading and result states in an asynchronous callback. If the component has been unmounted in the meantime, this results to a memory leak.

Reproduction

Just put the ReactTinyLink component in a modal, close the modal before the fetch is done "et voilà" 🚰

Possible fix

You could use a cleanup function in your useEffectAsync which cancels the fetch and sets a variable which prevents the fetchURL to set the state.

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

Successfully merging a pull request may close this issue.

1 participant