瀏覽代碼

fix: [Collapsible] remove useless isEqual compare in componentDidUpdate

zhangyumei.0319 10 月之前
父節點
當前提交
d71a32889a
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      packages/semi-ui/collapsible/index.tsx

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

@@ -9,7 +9,7 @@ import BaseComponent from "../_base/baseComponent";
 import PropTypes from "prop-types";
 import cls from "classnames";
 import { cssClasses } from "@douyinfe/semi-foundation/collapsible/constants";
-import { isEqual } from "lodash";
+import { isEqual, omit, pick } from "lodash";
 import "@douyinfe/semi-foundation/collapsible/collapsible.scss";
 import { getDefaultPropsFromGlobalConfig } from "../_utils";
 
@@ -123,8 +123,8 @@ class Collapsible extends BaseComponent<CollapsibleProps, CollapsibleState> {
     }
 
     componentDidUpdate(prevProps: Readonly<CollapsibleProps>, prevState: Readonly<CollapsibleState>, snapshot?: any) {
-        const changedPropKeys = Object.keys(this.props).filter(key => !isEqual(this.props[key], prevProps[key]));
-        const changedStateKeys = Object.keys(this.state).filter(key => !isEqual(this.state[key], prevState[key]));
+        const changedPropKeys = Object.keys(pick(this.props, ['reCalcKey', "isOpen"])).filter(key => !isEqual(this.props[key], prevProps[key]));
+        const changedStateKeys = Object.keys(pick(this.state, ['domInRenderTree'])).filter(key => !isEqual(this.state[key], prevState[key]));
         if (changedPropKeys.includes("reCalcKey")) {
             this.foundation.updateDOMHeight(this.domRef.current.scrollHeight);
         }