Shadcn Toast not showing using useEffect
Hello. I am trying to render a shadcn toast after a redirect from a server action, but first, I need to be able to render a toast on page load.
I can't figure out why this does not work... anyone here that has used this library might help?
Thanks in advance!
7 Replies
Did you add the
<Toaster/>
component in layout?Yes! It works when I render a toast on button click just not on useEffect
And the same happens in Sonner toasts btw
And the page is a client component?
Yes, I think it really is a Sonner bug
I made this stackblitz that perfectly demonstrates my problem:
https://stackblitz.com/edit/stackblitz-starters-hzwlsc?file=app%2Flayout.tsx
Weird but this hack fixes it:
Let me know if you find a real fix
Thank you for the tip! I openned an issue in the lib's github. Will let you know when something happens.