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

allow call of axios when unmounting #32

Open
fafo opened this issue Nov 14, 2019 · 2 comments
Open

allow call of axios when unmounting #32

fafo opened this issue Nov 14, 2019 · 2 comments

Comments

@fafo
Copy link

fafo commented Nov 14, 2019

Hi, #16 solves the problem of not updating the state after umounting by canceling the call.
However sometimes it desiderable to run the call when the component is unmounted (ex autosave on close). It could be resolved with an option allowing axios to run after unmount, but not setting the results in the state variables. If anybody thinks this is the correct approach I could try to write a patch.

@int64ago
Copy link
Member

It not recommend to do things after unmounting, it may cause memory leaking, the sate of axios after unmounting is undefined

@fafo
Copy link
Author

fafo commented Nov 15, 2019

The state of axios shouldn't be affected by the react state, therefore I don't see problems in the network call. Instead all side effects (result data, loading state, error) do cause problems, but it should be easy to avoid them since we are no more interested. In our code (we wrote an internal hook similar to this one) we just have a flag allowing to run the network call after unmont, but skipping any state change.
Otherwise any behavior like autosave on close becames very difficult

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

No branches or pull requests

2 participants