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.
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 thetransitionend
event listener. We added the event listener in thecomponentDidMount
method and removed it in thecomponentWillUnmount
method. This ensures that the_onAnimationComplete
method is called when a transition ends onthis.toastrBoxElement
, even in React 18.We also added checks to ensure
this.toastrBoxElement
is notnull
before adding or removing the event listener. This prevents potential errors ifthis.toastrBoxElement
isnull
.With these changes, toasts should now be removed as expected in React 18.