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

Using same Toast multiple times with canAutoClose #1016

Open
jamiek-acl opened this issue Apr 21, 2021 · 0 comments
Open

Using same Toast multiple times with canAutoClose #1016

jamiek-acl opened this issue Apr 21, 2021 · 0 comments
Labels
Bug 🐞 Something isn't working Editor's Choice Highlight an issue as something that would be great to be solve

Comments

@jamiek-acl
Copy link
Contributor

jamiek-acl commented Apr 21, 2021

The Toast has a canAutoClose prop which works fine the first time, but fails on subsequent uses of the Toast. For example:

  • have a button and when you press the button, the Toast appears
  • give the Toast the canAutoClose prop, so it closes automatically after a few seconds
  • after the Toast closes, if you press the button again, the Toast should appear again, but it doesn't

Nahum's clever work-around to make it work:

const [key, nextKey] = React.useState(0)
handleSomethingEventInYourApp() {
  nextKey(prev => prev + 1)
}
<Toast key={key} canAutoClose />

This should work without a clever work-around. From Nahum: "I think the Toast is missing the part of reseting its internal state after closing so it can be open again"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐞 Something isn't working Editor's Choice Highlight an issue as something that would be great to be solve
Projects
None yet
Development

No branches or pull requests

2 participants