question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AutoClose starts paused on very fast updates that include a change to `type`

See original GitHub issue

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

Bug

What is the current behavior?

I display a toast (autoClose: false) when a record starts saving, then update that toast to report success (autoClose: 5000) when the save is successfully complete. When the save is too fast, the 2nd state with the autoClose appears, but the autoClose is paused. Actions that unpause the toast (hover over and then out, change focus away from browser and the back) cause the timer to unpause and start it’s countdown.

I’ve determined that this occurs when you change the type of the toast and the time period between the first and second call are very fast (10ms in example below, from type: undefined to type: toast.TYPE.SUCCESS. If you keep the type the same, then everything works as expected (undefined to undefined, or SUCCESS to SUCCESS).

What is the expected behavior?

When the toast is updated from autoClose: false; type: undefined to autoClose: 5000; type: toast.TYPE.SUCCESS, the toast displays the countdown bar and begins to count down and then auto-closes.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

Chrome + Firefox, React 18

Reproduction: https://codesandbox.io/s/jovial-sound-lcd29q?file=/src/App.js

It took a couple iterations to nail it down to the type change AND elapsed time, so the example could probably be refined down further.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
fkhadracommented, Jun 25, 2022

Hey @tarwn, thanks for the codesanbox. I won’t have time to investigate the issue before 1 or 2 weeks (👶 incoming). Meanwhile, I can suggest a workaround. You can add a delay as follow

toast.update(toastId.current, {
        render: "Saved!",
        type: toast.TYPE.SUCCESS,
        autoClose: 5000,
        delay: 10 // this will do the trick
      });
0reactions
fkhadracommented, Aug 4, 2022

The issue could be related to https://github.com/fkhadra/react-toastify/issues/810. If you want to test a potential fix run

yarn add react-toastify@9.0.7-fix-autoclose-2
// or with npm
npm i react-toastify@9.0.7-fix-autoclose-2
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Enable or Disable Pause Updates Feature of Windows ...
Starting with Windows 10 version 1809, you can use a new group policy to remove access to " Pause updates " feature.
Read more >
How to turn off automatic updates in Windows 10 permanently
Windows updates are important, but sometimes they happen at inconvenient times. Windows 10 makes it possible to pause or disable automatic ...
Read more >
Enable, pause, or remove a campaign - Google Ads Help
Enable, pause, or remove a campaign. You can start, pause, or remove your campaigns. Pausing or removing a campaign will stop its ads...
Read more >
Pause and Resume Updates for Windows 11 Tutorial
Windows Update keeps Windows 11 updated by automatically downloading and installing the latest updates, drivers, and hotfixes released by ...
Read more >
MediaPlayer - Android Developers
It may take some time before the state is updated in calls to isPlaying() , and it ... Calling start() to resume playback...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found