diff --git a/package.json b/package.json index 5001002..140c978 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ }, "dependencies": { "@rc-component/motion": "^1.1.4", - "@rc-component/util": "^1.11.0", + "@rc-component/util": "^1.13.0", "clsx": "^2.1.1" }, "devDependencies": { diff --git a/src/Notification.tsx b/src/Notification.tsx index d7c5c28..ad9e529 100644 --- a/src/Notification.tsx +++ b/src/Notification.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import { clsx } from 'clsx'; import useNoticeTimer from './hooks/useNoticeTimer'; -import { useEvent } from '@rc-component/util'; +import { isNonNullable, isReactRenderable, useEvent } from '@rc-component/util'; import useClosable, { type ClosableType } from './hooks/useClosable'; import DefaultProgress from './Progress'; import type { NotificationProgressProps } from './Progress'; @@ -173,22 +173,20 @@ const Notification = React.forwardRef((props, const mergedNotificationIndex = notificationIndex ?? notificationIndexRef.current ?? 0; // ======================== Content ========================= - const titleNode = - title !== undefined && title !== null ? ( -
- {title} -
- ) : null; + const titleNode = isNonNullable(title) ? ( +
+ {title} +
+ ) : null; - const descNode = - description !== undefined && description !== null ? ( -
- {description} -
- ) : null; + const descNode = isNonNullable(description) ? ( +
+ {description} +
+ ) : null; const hasTitle = titleNode !== null; const hasDescription = descNode !== null; @@ -208,7 +206,7 @@ const Notification = React.forwardRef((props, contentNode = titleNode || descNode; } - if (icon !== undefined && icon !== null) { + if (isNonNullable(icon)) { contentNode = (
((props, ); } - const actionsNode = actions ? ( + const actionsNode = isReactRenderable(actions) ? (