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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add description in a promise #413

Closed
Noname968 opened this issue May 8, 2024 · 1 comment
Closed

How to add description in a promise #413

Noname968 opened this issue May 8, 2024 · 1 comment

Comments

@Noname968
Copy link

Describe the feature 馃摑:

How to add description to a promise success or error.

@mridul1024
Copy link

mridul1024 commented May 12, 2024

Hi,
I just look through the code and the return types for both success and error is defined as React.ReactNode | string. Given that you wish to display a header field that is followed by a description, you may attempt building your structure by enclosing it within an element and returning it as a response. The promise functionality does not have its own description field.

Example:

type ResponseType = {
  header: string;
  description: string;
}

toast.promise<ResponseType>(
  Promise.resolve({
    header: "Notification",
    description: "Test Description",
  }),
  {
    loading: "Loading...",
    success: (data: ResponseType) => {
      return (
        <div>
          <div className="font-semibold">{data.header}</div>
          <p>{data.description}</p>
        </div>
      );
    },
    error: "Error"
  }
);

I hope this answers your query 馃槆

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

No branches or pull requests

3 participants