-
Notifications
You must be signed in to change notification settings - Fork 50
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
Content removal ahead of time #106
Comments
The most likely reason for this is simply that onAfterClose did not exist at the time this package was originally drafted
|
@zenflow will it be changed? |
I think we should change it, but not to onAfterClose.. After a little experimentation, I found that neither onClose nor onAfterClose are ideal, since neither are called when the current modal is interrupted by another modal. Example: A modal is opened, and before it is closed, another modal opens. The onClose & onAfterClose methods will never be called for the first modal. This scenario is not typical, but is possible, and probably happens in some apps. In this scenario, the result is memory leaks and the possibly bugs (if the mounted react component has some activity based on timers, network, etc.). I think we should implement some new callback option(s) in the sweetalert2 package, where it's possible to implement "cleanup" code which we can rely on being called. For example, /cc @limonte |
Sounds like a great idea, but I don't know how to implement it 🤷♂️ Let's take this simple code: Swal.fire('one')
Swal.fire('two') Here |
@limonte I think we would need to:
@gverni Would love to get your thoughts on all of this |
Thank you for the suggestion @zenflow The related PR is ready for your review: sweetalert2/sweetalert2#1872 |
🎉 This issue has been resolved in version 3.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
sweetalert2-react-content/src/index.js
Line 45 in ec05a41
why not .onAfterClose? Unmounting happens before closing now and you can see jerking when the closing.
The text was updated successfully, but these errors were encountered: