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) ? (