Browse Source

fix: [Collapsible] remove useless isEqual compare in componentDidUpdate

zhangyumei.0319 10 months ago
parent
commit
d71a32889a
1 changed files with 3 additions and 3 deletions
  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);
         }