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.

updated toast sometimes has wrong styles

See original GitHub issue

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

bug

What is the current behavior?

when a toast is updated immediately, it is sometimes missing the correct classname. in the codesandbox example below, when the toast is updated to “success” type, it sometimes (the first time?) has “default” styling.

note that when the toast update is wrapped in setTimeout(..., 0) it seems to work fine.

also note, that this looks like a regression in version 8.2, in version 8.1.1 the toast updated correctly.

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:

https://codesandbox.io/s/boring-rain-x5ckbw?file=/src/App.js

What is the expected behavior?

toast should show correct styles for type when updated

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
fkhadracommented, Apr 19, 2022

@cpecorari can you try the latest major release. It’s still in RC but pretty stable if you want to give it a try. npm installl react-toastify@next

You can find the release note here https://fkhadra.github.io/react-toastify/migration-v9

1reaction
sgarcia-devcommented, Feb 24, 2022

Some additional information. I tried downgrading to 8.1.0 as @stefanprobst suggested, and the toast update issue went away. So there was definitely a change introduced at some point that caused this bug, in case that helps @fkhadra .

Also, something I noticed is the bug only happens consistently when I try to update notifications approximately less than 1 second. So for example, the following gets the styling bug (content updates correctly, type remains as “info” and doesn’t update to “success”)

const id = toast.info('Loading', { autoClose: false})
// Same issue in both of these statements
toast.update(id, { render: 'Done', type: 'success', autoClose: true })
// OR
setTimeout(() => {
  toast.update(id, { render: 'Done', type: 'success', autoClose: true })
}, 250)

HOWEVER, the moment I increased the timeout into something into the 750-1000ms range, the bug went away. It’s really strange, and it’s the only thing I can think out as far as repro information for the bug. Sorry I can’t link a Codepen or CodeSandbox.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Updating or Changing Your Printer Settings - Toast Central
Model - This will determine certain formatting styles for the receipts that print. If the wrong model is selected, receipts may print out...
Read more >
Toast is not rendered (react-toastify component) - Stack Overflow
My mistake was importing toast without {} curly braces because my course instructor did so. Try to change this:
Read more >
Toasts - Bootstrap
Push notifications to your visitors with a toast, a lightweight and easily customizable alert message. Toasts are lightweight notifications designed to mimic ...
Read more >
Toast | Workbench by Gusto
Toast is a static component that is dynamically displayed via React Portals; Toaster and ToastContext are only required ONCE within your app.
Read more >
Toast - Zag.js
The toast component is used to give feedback to users after an action has taken place. 0.2.5 (latest) ... Can remove or update...
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