Skip to content

Commit

Permalink
fix: toast not displaying when Toaster.duration is set to Infinity (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
atsixian authored Mar 20, 2024
1 parent 9ddf580 commit 26658d3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ const Toast = (props: ToastProps) => {
};

const startTimer = () => {
// setTimeout(, Infinity) behaves as if the delay is 0.
// As a result, the toast would be closed immediately, giving the appearance that it was never rendered.
// See: https://github.com/denysdovhan/wtfjs?tab=readme-ov-file#an-infinite-timeout
if (remainingTime === Infinity) return;

closeTimerStartTimeRef.current = new Date().getTime();

// Let the toast know it has started
Expand Down

0 comments on commit 26658d3

Please sign in to comment.