Skip to content

An opinionated toast component for React.

fix: toast not displaying when `Toaster.duration` is set to Infinity (#373)

Sixian Li26658d3afafc
diff --git a/src/index.tsx b/src/index.tsx
index b3ac8d1..765463b 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -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