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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First toast showed toast.update always trigger toast destruction #294

Closed
PhilipGarnero opened this issue Dec 18, 2018 · 4 comments
Closed
Assignees
Labels

Comments

@PhilipGarnero
Copy link

Currently, the first toast displayed at load flickers when you try to update it.
This is due to the Toast component being destroyed then recreated.

I thought it was on my part so I investigated the issue and found the bug. It was a long task but the bug itself is pretty trivial:
When creating a toast, you assign them a key in order to provide react with the key attribute here. The problem is that the first key is 0 and in the case of an update, while the first key is effectively retrieved from the ToastContainer, it does not pass this check here resulting in the key not being used and being incremented instead. The fix would simply be to set toastKey here to 1 instead of 0.

To reproduce, simply create a single toast, and try to update it before it vanishes. It should call onClose and cause a flicker and the screen. Sorry for not providing code but you have the fix instead ;)

@fkhadra
Copy link
Owner

fkhadra commented Dec 18, 2018

Hey @PhilipGarnero,

I feel dumb 😭. It's so obvious, thank for the feedback, appreciate!

@fkhadra fkhadra added the bug label Dec 18, 2018
@fkhadra fkhadra self-assigned this Dec 18, 2018
fkhadra added a commit that referenced this issue Dec 18, 2018
@fkhadra
Copy link
Owner

fkhadra commented Dec 18, 2018

@PhilipGarnero fix released

@fkhadra fkhadra closed this as completed Dec 18, 2018
@PhilipGarnero
Copy link
Author

I feel dumb

Well don't. This was an edge case and it could happen to anyone.
I know how hard and time consuming maintaining an open-source project is
Thank you for your reactivity
Keep up the good work !

@ndravikumar
Copy link

ndravikumar commented Apr 27, 2020

I am using react-toastify and i am getting same as above bug please can you help.
I am using this version "react-toastify": "^5.5.0",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants