From 2951f5c07c4dc537150c83e6985348fc2196f20e Mon Sep 17 00:00:00 2001 From: krisantrobus <55083528+krisantrobus@users.noreply.github.com> Date: Thu, 5 Sep 2024 10:15:28 -0500 Subject: [PATCH] fix(toaster): resolved issue where multiple toasts were not being dismissed (#4058) --- .changeset/curly-ants-report.md | 6 ++++++ packages/paste-core/components/toast/src/useToaster.ts | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/curly-ants-report.md diff --git a/.changeset/curly-ants-report.md b/.changeset/curly-ants-report.md new file mode 100644 index 0000000000..866a403a20 --- /dev/null +++ b/.changeset/curly-ants-report.md @@ -0,0 +1,6 @@ +--- +"@twilio-paste/toast": patch +"@twilio-paste/core": patch +--- + +[Toast] resolved issue where multiple toasts were not being dismissed diff --git a/packages/paste-core/components/toast/src/useToaster.ts b/packages/paste-core/components/toast/src/useToaster.ts index d1af9cf0e8..19284345a2 100644 --- a/packages/paste-core/components/toast/src/useToaster.ts +++ b/packages/paste-core/components/toast/src/useToaster.ts @@ -14,13 +14,14 @@ export const useToaster = (): UseToasterReturnedProps => { /** * Clear all timeouts from the toaster when the component unmounts */ + toasts.forEach((toast) => { if (toast.timeOutId) { window.clearTimeout(toast.timeOutId); } }); }; - }, [toasts]); + }, []); const pop = (id: ToasterToast["id"]): void => { if (!isMounted.current) {