Skip to content

Using same Toast multiple times with canAutoClose #1016

@jamiek-acl

Description

@jamiek-acl

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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug 🐞Something isn't workingEditor's ChoiceHighlight an issue as something that would be great to be solve

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions