myxvisual / react-uwp

📱⌨ React Components that Implement Microsoft's UWP Design & Fluent Design.
https://react-uwp.com
MIT License
1.18k stars 78 forks source link

Toast component does not work #115

Open sauravhiremath opened 3 years ago

sauravhiremath commented 3 years ago

Problem description

class Lobby extends React.Component {
  state = {
    warning: [false, undefined, undefined],
  };

  showWarning = (warning) => {
    return (
      <Toast
        showCloseIcon
        closeDelay={3000}
        defaultShow={warning[0]}
        title={warning[1]}
        description={[warning[2]]}
        onToggleShowToast={(isToast) => {
          if (isToast) {
            this.setState({ warning: [false, undefined, undefined] });
          }
        }}
      />
    );
  };

  render() {
    return (
      <Row>
        <Col>{this.showWarning(warning)}</Col>
        <Col>
          <Button
            onClick={() =>
              this.setState({ warning: [true, "title", "description"] }, () => {
                console.log("updated warning state", this.state.warning);
              })
            }
          />
        </Col>
      </Row>
    );
  }
}

For some weird reason, the Toast popup does not paint on the window screen. Because the state values are updated perfectly as seen from devtools view.

I've created a sandbox to reproduce the case. Although this works but has unexpected behaviors when triggered multiple times.

Edit Toast Preview

Versions