react-toastify icon indicating copy to clipboard operation
react-toastify copied to clipboard

Resolving promise before (delayed) toast is shown results in toast being stuck in pending state

Open sowizz opened this issue 3 years ago • 1 comments

Do you want to request a feature or report a bug?

Report a bug (?)

What is the current behavior? If a promise resolves before the delayed toast is shown, the toast will not leave pending state, thus it will never leave the screen. I'm not even sure if that qualifies as a bug.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your CodeSandbox (https://codesandbox.io/s/new) example below:

  1. Display delayed toast, let say by 500ms.
  2. Resolve promise immediately.

What is the expected behavior? Not sure.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? React: ^17.0.2 Chrome: 97.0.4692.71 | MacOS

sowizz avatar Jan 25 '22 16:01 sowizz

Concerning the expected behavior, the toast should not appear except if autoClose is set to "false".

I created some views with some basic toasts (loading/success/error) on an API call and I don't want to show the loading toast if it's very quick to avoid the default behavior where it appears and desappears very quickly.

I read the documentation but I did not find how to do this for now. I will post it here if I found a way for doing it.

Edit: I created a PR: https://github.com/fkhadra/react-toastify/pull/729

Tested with /example and it seems to work. I Will add some informations about it later

git-angelo avatar Mar 28 '22 08:03 git-angelo

Addressed in v9

fkhadra avatar Mar 10 '23 03:03 fkhadra