react-hot-toast
react-hot-toast copied to clipboard
Support multiple <Toaster> elements
This might be outside of the scope for this project, but the ability to have multiple <Toaster>
elements on a page (where toast()
calls could have a ToasterID
passed in) would be pretty cool and add a lot flexibility.
Example:
toast('This appears as a toast relative to the <div> parent', relativeToasterId)
toast('This appears as a normal toast')
...
return (
<>
<div>
<Toaster id={relativeToasterId} />
</div>
<Toaster />
</>
)
Hi @mrmiguu! Great suggestion - considered this for v2, but decided not to do it atm.
Let's use this issue to see how the demand is. 👍
This would be super helpful.
Please, consider, would be amazing feature
https://github.com/timolins/react-hot-toast/pull/159 ☝️☝️☝️
This PR, if merged, essentially works like this:
toast('hello', { toasterId: 'unique-id-here' })
...
<Toaster toasterId="unique-id-here" />
This way, only that Toaster will be able to receive toast
s to-and-from the string "unique-id-here"
.
looking forward to having this!
hi all, how about this
This would be an extremely valuable feature! Please consider adding.
Yeah. That is what we need right now. For now we will have to support a different functionality with the same behavior.
My guess is that this doesn't use React Context yet.
If there could be something like a <ToastProvider>
, you could use that multiple times and even nest them, where the innermost provider determines which one should be used. That could be really useful if you have one for general app messages, and another one inside of a sidebar or something like that.
I also noticed that it doesn't work out-of-the-box when you have a component library (in a different package) and want to toast things from there to the main app. A context could make that really easy, but for now I just passed the toast()
function to our own context and retrieve it from there rather than importing it.
Any updates on this?
pls ser?
This would be an extremely valuable feature!
+1, would definitely be helpful. Having to do some workarounds right now to get toasts to work with headless UI dialogs.
Please consider this feature :)
This would be a great feature,hands down
would love to have this feature as well
+1 I need some toasts to overlay on my video player
Any news? It would be a great feature.
Any news? It would be a great feature.