diegoddox / react-redux-toastr

react-redux-toastr is a toastr message implemented with Redux
http://diegoddox.github.io/react-redux-toastr/
MIT License
752 stars 149 forks source link

No support for multiple toastr instances #276

Open gowikel opened 2 years ago

gowikel commented 2 years ago

Hi on our application we are using two instances of a toastr component. One of them is global and is instantiated straight away in the root component. But our users can see a portion of the application in fullscreen and we instantiate another toastr component when we move to fullscreen. We realised that when the second one unmounts, the global one stops working. Inspecting the code we saw that the unmounting toastr removes all listeners breaking the communication of the global one.

diegoddox commented 2 years ago

Hi @gowikel, the easiest way to solve this will be to add another prop like removeEventEmitterOnUnmount here which is default to true and in componentWillUnmount we could check for it and preventing from removing the listeners based on that.