tomchentw/react-toastr

Unable to open more than one toast simultaneously.

petertdinh opened this issue · 2 comments

Assuming that this is my code:

someFunction = () => {
  [Strings].forEach(string => renderToast(string));
}

renderToast = str => {
  const options = { tapToDismiss: true, timeOut: 4000 };
  this.container.success(str, null, options);
}

<ToastContainer
   ref={input => this.container = input}
   preventDuplicates={false}
/>

I am only able to render one toast per someFunction call, even if [Strings] has anywhere from 2-100 elements. If someFunction was attached to an onClick prop, and I were to click it multiple times, one toast will pop up per click. This issue is unrelated to #62

whns commented

Just submitted a pr that should take care of it (#122). I think throwing a short setTimeout around your this.container.success call would also work, although that's not ideal.

@whns Awesome! Agree that the setTimeout isn't ideal but it's a good fallback until your changes get merged. Thanks!