Skip to content

Loading state of a toast isn't removed when using toast() with the same ID of the toast.loading() #401

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

Open
webdevelukas opened this issue Apr 10, 2024 · 6 comments

Comments

@webdevelukas
Copy link

webdevelukas commented Apr 10, 2024

Describe the feature / bug 📝:

If I create a toast with toast.loading('loading', { id: 'test' }) and I later call toast('not loading anymore', { id: 'test' }) which for my expectation should remove the loading state from the toast. It doesn't do that. It just switches the text, but it stays in the loading state. I want to do it like this because I just want to show a "neutral" toast when the loading is finished and I don't want to use a toast.success or something similar because of the styling.

Steps to reproduce the bug 🔁:

I've tested it in v1.4.0 and the latest v1.4.41

  1. I added two buttons in a Next.js project
 <button type='button' onClick={() => toast.loading('loading', { id: 'test' })}>Set loading</button>
 <button type='button' onClick={() => toast('not loading anymore', { id: 'test' })}>Remove loading</button>
  1. Click the "Set Loading" Button and the toast appears showing the spinner and "loading".
  2. Click the "Remove Loading" Button and the toast is still showing the spinner but with "not loading anymore".
    image
@ankitn1311
Copy link

You can remove the loading toast using toast.dismiss('test')

@webdevelukas
Copy link
Author

webdevelukas commented Mar 3, 2025

You can remove the loading toast using toast.dismiss('test')

This will dismiss the whole toast, while I just wanted to dismiss the loading spinner. My expectation was, that calling toast() will remove the loading state that I've previously enabled with toast.loading(). If I call toast.success() on the same toast for example. It will switch the toasts state from loading to success.

@programming-with-ia
Copy link

programming-with-ia commented May 20, 2025

it's working now

@programming-with-ia
Copy link

Enhancement Suggestion
It would be helpful to add a utility function like createToastCreator that accepts a base config/options object and returns a custom toast function. This way, we could reuse the same options (e.g., position, duration, styling, id) across multiple toasts without repeating them each time.

@webdevelukas
Copy link
Author

it's working now

I've tested it with version 2.0.3 and I still have the same behaviour as I described.

@programming-with-ia
Copy link

programming-with-ia commented May 22, 2025

@webdevelukas
try toast.* instead of toast()

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