From 6c51bc8558b088cb3d253a5741cc76338c227006 Mon Sep 17 00:00:00 2001 From: peetzweg/ <839848+peetzweg@users.noreply.github.com> Date: Wed, 10 Apr 2024 09:27:44 +0200 Subject: [PATCH] fix: rendering of `ReactNode` descriptions (#387) --- src/index.tsx | 8 ++++++-- test/src/app/page.tsx | 14 ++++++++++++++ test/tests/basic.spec.ts | 10 ++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 802c367..4260166 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -403,8 +403,12 @@ const Toast = (props: ToastProps) => { classNames?.description, toast?.classNames?.description, )} - dangerouslySetInnerHTML={sanitizeHTML(toast.description as string)} - > + dangerouslySetInnerHTML={ + typeof toast.description === 'string' ? sanitizeHTML(toast.description as string) : undefined + } + > + {typeof toast.description === 'object' ? toast.description : null} + ) : null} {React.isValidElement(toast.cancel) ? ( diff --git a/test/src/app/page.tsx b/test/src/app/page.tsx index 598cf3d..bb121c6 100644 --- a/test/src/app/page.tsx +++ b/test/src/app/page.tsx @@ -155,6 +155,20 @@ export default function Home({ searchParams }: any) { > Updated Toast + + {showAutoClose ?
: null} {showDismiss ? : null}