Browse Source

fix: only compare key to determine whether to update the item

linyan 2 years ago
parent
commit
c24a1517c1
1 changed files with 8 additions and 1 deletions
  1. 8 1
      packages/semi-ui/overflowList/index.tsx

+ 8 - 1
packages/semi-ui/overflowList/index.tsx

@@ -170,8 +170,15 @@ class OverflowList extends BaseComponent<OverflowListProps, OverflowListState> {
 
 
     componentDidUpdate(prevProps: OverflowListProps, prevState: OverflowListState): void {
     componentDidUpdate(prevProps: OverflowListProps, prevState: OverflowListState): void {
 
 
+        const prevItemsKeys = prevProps.items.map((item) =>
+            item.key
+        );
+        const nowItemsKeys = this.props.items.map((item) =>
+            item.key
+        );
 
 
-        if (!isEqual(prevProps.items, this.props.items)) {
+        // Determine whether to update by comparing key values
+        if (!isEqual(prevItemsKeys, nowItemsKeys)) {
             this.itemRefs = {};
             this.itemRefs = {};
             this.setState({ visibleState: new Map() });
             this.setState({ visibleState: new Map() });
         }
         }