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

Fix Toastr Removal Issue in React 18 #287

Merged
merged 4 commits into from
Sep 20, 2023
Merged

Conversation

jefferdo
Copy link
Contributor

In this pull request, we have addressed an issue where toasts were not being removed as expected in React 18. The problem was due to changes in how React 18 handles and batches updates, which affected the onCSSTransitionEnd function.

To resolve this, we replaced the onCSSTransitionEnd function with direct usage of the transitionend event listener. We added the event listener in the componentDidMount method and removed it in the componentWillUnmount method. This ensures that the _onAnimationComplete method is called when a transition ends on this.toastrBoxElement, even in React 18.

We also added checks to ensure this.toastrBoxElement is not null before adding or removing the event listener. This prevents potential errors if this.toastrBoxElement is null.

With these changes, toasts should now be removed as expected in React 18.

Copy link
Owner

@diegoddox diegoddox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot 🙏

@diegoddox diegoddox merged commit 6bba116 into diegoddox:master Sep 20, 2023
@uditkhanna112
Copy link

This issue is not resolved yet, it works only if we work in Non strict mode.

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 this pull request may close these issues.

None yet

3 participants