From 7d28d42b368fd65f02d1d903c673111f3a430701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ph=C3=A1t?= Date: Thu, 23 May 2024 14:33:34 +0700 Subject: [PATCH] feat: updates toast action/cancel property type/handlers (#398) * feat: update action `type` and helper function * feat: handle action/cancel optional onClick property --- src/index.tsx | 7 ++++--- src/types.ts | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 9a2adc5..fa76ce3 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -424,8 +424,8 @@ const Toast = (props: ToastProps) => { // We need to check twice because typescript if (!isAction(toast.cancel)) return; if (!dismissible) return; + toast.cancel.onClick?.(event); deleteToast(); - toast.cancel.onClick(event); }} className={cn(classNames?.cancelButton, toast?.classNames?.cancelButton)} > @@ -436,13 +436,14 @@ const Toast = (props: ToastProps) => { toast.action ) : toast.action && isAction(toast.action) ? (