diff --git a/src/index.tsx b/src/index.tsx index 4260166..61de247 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -422,8 +422,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)} > @@ -434,13 +434,14 @@ const Toast = (props: ToastProps) => { toast.action ) : toast.action && isAction(toast.action) ? (