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(): promise optional success/error msg #179

Merged
merged 4 commits into from
Dec 21, 2024

Conversation

n33pm
Copy link
Contributor

@n33pm n33pm commented May 4, 2022

In some cases there is no success or error msg
eg. redirect after success.

@vercel
Copy link

vercel bot commented May 4, 2022

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

Name Status Preview Comments Updated (UTC)
react-hot-toast ❌ Failed (Inspect) Dec 21, 2024 10:16am

@McSam94
Copy link

McSam94 commented Jul 11, 2022

any update on this PR?

@rcbevans
Copy link

Been trying to figure out how to skip error messages in the case of user cancellation, is there anything holding up getting this in?

...opts?.success,
});
if (msgs.success)
toast.success(resolveValue(msgs.success, p), {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existing ValueOrFunction allows for null as a return value, it also seems reasonable that if a user returns null from the success/error function it could skip the toast. This seems preferable since especially in the case of errors, whether to show an error may itself be conditional on the type of Error raised.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree! Added this behaviour as well.

@timolins
Copy link
Owner

Sorry for the long wait! Made two small changes:

  • Use toast.dismiss instead of toast.remove for a smoother exit
  • Also trigger this behaviour if returned message is empty as suggested by @rcbevans

Merging now 👍

@timolins timolins merged commit 25bd873 into timolins:main Dec 21, 2024
1 of 2 checks passed
@timolins
Copy link
Owner

timolins commented Dec 31, 2024

This is now released with 2.5.1! 🥳

@n33pm n33pm deleted the feat/promiseOptionalMsg branch December 31, 2024 22:50
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.

4 participants