From f4f931b0f4b3202ccf59cfc11066a872678bddc1 Mon Sep 17 00:00:00 2001 From: p-sw Date: Wed, 29 May 2024 20:32:43 +0900 Subject: [PATCH] fix: add timeout on born transition of toast to handle faster toast creation --- packages/react/components/Toast.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/react/components/Toast.tsx b/packages/react/components/Toast.tsx index f0a45b4..e34140a 100644 --- a/packages/react/components/Toast.tsx +++ b/packages/react/components/Toast.tsx @@ -170,11 +170,13 @@ const ToastTemplate = ({ React.useEffect(() => { if (toastData.life === "born") { - toasts[id] = { - ...toasts[id], - life: "normal", - }; - notifySingle(id); + setTimeout(() => { + toasts[id] = { + ...toasts[id], + life: "normal", + }; + notifySingle(id); + }, 5 /* transition not working on fast toast creation with small timeout value */); } if (toastData.life === "normal" && toastData.closeTimeout !== null) { const timeout = setTimeout(() => {