Skip to content

An opinionated toast component for React.

types: change label types to ReactNode (#280)

Can Rau6a9460389699
diff --git a/src/index.tsx b/src/index.tsx
index 06f05e8..7afdb9a 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -360,11 +360,11 @@ const Toast = (props: ToastProps) => {
data-button
data-cancel
style={toast.cancelButtonStyle || cancelButtonStyle}
- onClick={() => {
+ onClick={(event) => {
if (!dismissible) return;
deleteToast();
if (toast.cancel?.onClick) {
- toast.cancel.onClick();
+ toast.cancel.onClick(event);
}
}}
className={cn(classNames?.cancelButton, toast?.classNames?.cancelButton)}
diff --git a/src/types.ts b/src/types.ts
index 489b369..eab1a96 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -42,12 +42,12 @@ export interface ToastT {
delete?: boolean;
important?: boolean;
action?: {
- label: string;
+ label: React.ReactNode;
onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
};
cancel?: {
- label: string;
- onClick?: () => void;
+ label: React.ReactNode;
+ onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
};
onDismiss?: (toast: ToastT) => void;
onAutoClose?: (toast: ToastT) => void;