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

Dismount when changing url #115

Open
vtni opened this issue Jul 17, 2019 · 3 comments
Open

Dismount when changing url #115

vtni opened this issue Jul 17, 2019 · 3 comments

Comments

@vtni
Copy link

vtni commented Jul 17, 2019

When changing the url (clicking browsers back button), the component is unmounted, but still visible. Is it possible to hide then also the SweetAlert dialog? I tried it with forceUpdate(), but the rendering method is not called anymore after componentWillUnmount().

Thank you

@ViniciusGularte
Copy link

I fixed this using the event triggered by the back button to update the alert state

componentDidUpdate(){ window.onpopstate = (e) => { this.setState({ alert:false }) } }

@rubinchyk
Copy link

In Chrome 77 "window.onpopstate" working only after user interaction.

I fixed this using the event triggered by the back button to update the alert state

componentDidUpdate(){ window.onpopstate = (e) => { this.setState({ alert:false }) } }

@vtni
Copy link
Author

vtni commented Oct 19, 2019

I fixed this using the event triggered by the back button to update the alert state

componentDidUpdate(){ window.onpopstate = (e) => { this.setState({ alert:false }) } }

Unfortunately, I get the same error:

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.

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

3 participants