Browse Source

fix: fix overflow key error

(cherry picked from commit 97d73485568b065e1eae867f6a2fe4a92862433b)
代强 2 years ago
parent
commit
ae504639e1
1 changed files with 3 additions and 3 deletions
  1. 3 3
      packages/semi-ui/overflowList/index.tsx

+ 3 - 3
packages/semi-ui/overflowList/index.tsx

@@ -278,12 +278,12 @@ class OverflowList extends BaseComponent<OverflowListProps, OverflowListState> {
                         const child = React.cloneElement(element);
                         return (
                             <ResizeObserver
-                                key={key}
+                                key={key ?? idx}
                                 onResize={([entry]) => this.onItemResize(entry, item, idx)}
                             >
                                 {/* 用div包起来,可以直接在resize回调中拿到宽度,不用通过获取元素的padding, margin, border-width求和计算宽度*/}
                                 {/* This div wrap can get width directly rather than do the math of padding, margin, border-width*/}
-                                <div key={key} className={`${prefixCls}-item`}>
+                                <div key={key ?? idx} className={`${prefixCls}-item`}>
                                     {child}
                                 </div>
                             </ResizeObserver>);
@@ -348,4 +348,4 @@ class OverflowList extends BaseComponent<OverflowListProps, OverflowListState> {
     }
 }
 
-export default OverflowList;
+export default OverflowList;