diff --git a/src/index.tsx b/src/index.tsx index a1a0e9a..e8b8a41 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -44,7 +44,7 @@ const Toast = (props: ToastProps) => { toasts, expanded, removeToast, - closeButton, + closeButton: closeButtonFromToaster, style, cancelButtonStyle, actionButtonStyle, @@ -77,6 +77,10 @@ const Toast = (props: ToastProps) => { () => heights.findIndex((height) => height.toastId === toast.id) || 0, [heights, toast.id], ); + const closeButton = React.useMemo( + () => toast.closeButton ?? closeButtonFromToaster, + [toast.closeButton, closeButtonFromToaster], + ); const duration = React.useMemo( () => toast.duration || durationFromToaster || TOAST_LIFETIME, [toast.duration, durationFromToaster], @@ -295,7 +299,7 @@ const Toast = (props: ToastProps) => { } }} > - {(closeButton || toast.closeButton) && !toast.jsx ? ( + {closeButton && !toast.jsx ? (