Hello,
I'm facing a problem displaying my toast.
I have a main project wich as another project as a dependency. This project is a minified library that i referenced with npm.
In the main project I set the
If I call the method toast() from the library the toast is not display. It is display if I call toast from the main project.
I tried to things :
I think the Toaster doesn't find the ToastContainer in the main project when the toast() is imported in the
library.
Do you have any clue?
For the moment I'm passing the toast() as a props to my library but I don't like it...
Hello @alb3ric ,
Is it possible to reproduce your setup?
The lib doesn't work with 2 ToastContainer for the moment .
Hello @fkhadra,
I'm going to try to make a small project reproducing the problem. I keep you in touch when it s done.
Hello @fkhadra
I did 2 test repository.
You can find the repository for the library here : https://github.com/alb3ric/ToastLib.git
And a repository with a project consuming the library : https://github.com/alb3ric/ToastTest.git
The ToastTest project reference the ToastLib library using : yarn add https://github.com/alb3ric/ToastLib.git
Launching TestToast :
If you execute the ToastTest you can see that the toast is not showing when clicking the test button but showing is clicking the button "test ref".
Hope it helps :)
Thanks @alb3ric, I'll try to have a look at this ASAP.
Hello @alb3ric,
The ToastTest project is not working as expected because it seems that 2 instances of react-toastify are running. You can see that after having a look at the webpack bundle generated by the ToastTest project:


The library uses an event manager(just a pubsub in fact) to dispatch the notifications. The so-called event manager is bound to the toast object. With the current setup 2 toast object are created.
Maybe you need to adapt the webpack config of ToastLib. I found an interesting issue here.
I'll try to dig more.
Hello @fkhadra
Thx for the input. I'm currently on holidays, I ll try that as soon as I come back! I keep you in touch!
Best regards and thanks for your great work!
You're welcome @alb3ric bonne vacances!
@fkhadra is this issue solved ?
I have the same problem
Before declaring your class, add the following line:
toast.configure();
Most helpful comment
Before declaring your class, add the following line:
toast.configure();