react-toastify
react-toastify copied to clipboard
Limit the waiting queue to 2 toasts
Do you want to request a feature or report a bug? feature
What is the current behavior?
When using limit
, all pending toasts will be queued. Coming after a while, toasts will start playing from the most recent to the oldest one.
What is the expected behavior?
We would like to keep a limit=1
with a queueMax=2
(property not existing at the moment), so that we aren't spammed by toasts when coming back to the page after a while, especially since old toasts have become irrelevant by now.
We want to keep the 2 most recent notifications in the queue, thus the newest toast should remove the second oldest toast from the queue.
Would it be possible to add this new property to a container ? Or maybe add another param to ClearWaitingQueueParams
when calling toast.clearWaitingQueue
?
Thank you for considering this feature.
Hey @AdrienLemaire, I'll check if this can be implemented without too much hassle.
I was wondering the exact same thing. At the moment, I have a toast for a login button with a limit={2}. When the user doesn't exist, it shows an error message. The idea is to limit the error messages to {2}, with a queueMax=0 (is it currently possible to do such thing)? Like, I don't want a queue at all.
I was wondering the exact same thing. At the moment, I have a toast for a login button with a limit={2}. When the user doesn't exist, it shows an error message. The idea is to limit the error messages to {2}, with a queueMax=0 (is it currently possible to do such thing)? Like, I don't want a queue at all.
I just found a solution for that btw, I just used a custom id to avoid duplicates:
toast.error("Utilisateur non trouvé", {
toastId: "toastAvoidsDuplicates",
});
nice :)
It would also be interesting to disable the queue completely. In my case I would prefer that a notification sent while the limit is full got lost.
@AdrienLemaire @xdebbie @ceconcarlsen @vitorbertolucci Hi, you can find the changes you've been waiting for in the pull request above. I hope you will like my implementation.
ToastContainer now has a queueLimit property, thanks to which we can set the maximum queue length, or if we want to turn it off completely, we can give queueLimit equal to 0.