Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Toaster, toast): #158 Support multiple, distinct Toasters by id #159

Closed

Conversation

mrmiguu
Copy link

@mrmiguu mrmiguu commented Mar 11, 2022

What

<Toaster> and toast() currently have no way of communicating
distinctly if there exists multiple Toaster elements throughout. Add a
way for toast calls to "pop up" exclusively from any specific Toaster

Changes

Add toasterId to <Toaster> props

Add toasterId to all toast*() calls under the options? arg

…s by id

# What

`<Toaster>` and `toast()` currently have no way of communicating
distinctly if there exists multiple Toaster elements throughout. Add a
way for toast calls to "pop up" exclusively from any specific Toaster

# Changes

Add `toasterId` to `<Toaster>` props

Add `toasterId` to all `toast*()` calls under the `options?` arg
@vercel
Copy link

vercel bot commented Mar 11, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/timo/react-hot-toast/Gugjg2MLUq7odnwhata5Jwt7HnuW
✅ Preview: https://react-hot-toast-git-fork-mrmiguu-support-multiple-07c6bd-timo1.vercel.app

@timolins
Copy link
Owner

Hi @mrmiguu! Thanks for you PR.

I haven't tried it out yet, but it looks like there will be issues with the offset calculation. The current implementation prevents rendering of toasts with a different id, but they are still used inside the calculateOffset function.

Ideally we pass the ID to useToaster (which then passes it to useStore), so the state can take the id into consideration. Adding option support to the useToaster hook would also allow us to introduce other options like toastLimit (#31)

@mrmiguu mrmiguu closed this Apr 12, 2022
@joshsny
Copy link

joshsny commented May 20, 2022

This looked like it was going to be so great 😢 Thanks for the work on it @mrmiguu!

@timolins
Copy link
Owner

timolins commented Jan 6, 2025

I picked up work on this feature again in #383 again. Very excited for it.

Here is a hosted example of the new docs for it: https://react-hot-toast-git-multi-toaster-timos-team.vercel.app/docs/multi-toaster

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants