Browse Source

fix: fix notification type define of id (#1993)

代强 1 year ago
parent
commit
04fe071c39

+ 3 - 3
packages/semi-foundation/notification/notificationFoundation.ts

@@ -10,16 +10,16 @@ export type NoticeTheme = 'light' | 'normal';
 
 export interface NoticeProps {
     duration?: number;
-    id?: string | number;
+    id?: string;
     title?: any;
     content?: any;
     position?: NoticePosition;
     type?: NoticeType;
     onClick?: (e: any) => void;
     onClose?: () => void;
-    onCloseClick?: (id: string | number) => void;
+    onCloseClick?: (id: string) => void;
     showClose?: boolean;
-    close?: (id: string | number) => void;
+    close?: (id: string) => void;
     zIndex?: number;
     icon?: any;
     getPopupContainer?: () => HTMLElement;

+ 2 - 2
packages/semi-ui/notification/index.tsx

@@ -193,13 +193,13 @@ class NotificationList extends BaseComponent<NotificationListProps, Notification
 
     has = (id: string) => this.foundation.has(id);
 
-    remove = (id: string | number) => {
+    remove = (id: string) => {
         this.foundation.removeNotice(String(id));
     };
 
 
 
-    update = (id: string|number, opts: NoticeProps)=>{
+    update = (id: string, opts: NoticeProps)=>{
         return this.foundation.update(id, opts);
     }
 

+ 1 - 1
packages/semi-ui/notification/notice.tsx

@@ -33,7 +33,7 @@ class Notice extends BaseComponent<NoticeReactProps, NoticeState> {
     static contextType = ConfigContext;
     static propTypes = {
         duration: PropTypes.number,
-        id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
+        id: PropTypes.string,
         title: PropTypes.node,
         content: PropTypes.node, // strings、numbers、array、element
         type: PropTypes.oneOf(types),