timolins / react-hot-toast

Smoking Hot React Notifications 🔥
https://react-hot-toast.com
MIT License
9.73k stars 323 forks source link

Toast persists after page navigation #340

Open simerlec opened 8 months ago

simerlec commented 8 months ago

Hello 👋

thank you for the lib.

I believe I've found an issue when using it in a Nextjs application on page navigation. Here's a repo for what I encountered https://stackblitz.com/edit/stackblitz-starters-tvmp57?file=app%2Fpage.tsx&file=app%2Fpage2%2Fpage.tsx

The gist of it is, that we have a link to another page in one of our toasts and are dismissing it right after the user clicks the link. So toast shows up -> user clicks link in the toast -> dismiss (all) toast(s) -> navigate to new page. What happens now is that the dismiss call does not really work here. The toast briefly show up on the new page (and on subsequent navigations as well, which is especially jarring). Can it be the case that the navigation somehow interferes with the complete removal of the toast? I read in the docs that the dismiss function only triggers the exit animation and the toast gets removed after 1 second. Is that the problem here?

thank you and kind regards

Chris

ParallelUniv3rse commented 7 months ago

Seems like duplicate of #128