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

Handle async functions in toast.promise results #389

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ajmnz
Copy link
Contributor

@ajmnz ajmnz commented Mar 28, 2024

Issue:

Async functions in toast.promise will lead to toasts with the message: [object Promise]

What has been done:

  • Added an optional Promise<React.ReactNode> return type on the success, error and description functions of toast.promise.
  • Awaited the success, error and description functions.
  • Cleaned up ts-expect-error declarations marked as todo, by introducing a type guard for the Response type.

Screenshots/Videos:

Screenshot 2024-03-28 at 17 44 02

@emilkowalski Any reason why toast.promise doesn't return a promise that resolves when its input promise resolves? Any chance I can implement #339 ?

Copy link

vercel bot commented Mar 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sonner ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 14, 2024 2:44pm

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.

None yet

1 participant