timolins / react-hot-toast

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

Indicate that promise messages may be functions, fixes #106 #117

Open BenJenkinson opened 3 years ago

BenJenkinson commented 3 years ago

Example

This already works in plain JS, but now it also works in TypeScript.

toast.promise(myPromise, {
  loading: "Loading",
  success: (data) => (toast) =>
    (
      <div>
        <span>Successfully saved ${data.name}</span>
        <button type="button" onClick={() => toast.dismiss(t.id)}>
          ⭐ Custom dismiss button in a promise toast
        </button>
      </div>
    ),
  error: (err) => `This just happened: ${err.toString()}`,
});
vercel[bot] commented 3 years ago

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/4eFWeXm2C77BrtbHuRRkp7AeRYQ7
✅ Preview: https://react-hot-toast-git-fork-benjenkinson-dismiss-prom-089eca-timo1.vercel.app