From d71a32889ae5cfe9a219e00f6de45bdcd025384d Mon Sep 17 00:00:00 2001 From: "zhangyumei.0319" Date: Fri, 13 Dec 2024 10:54:38 +0800 Subject: [PATCH] fix: [Collapsible] remove useless isEqual compare in componentDidUpdate --- packages/semi-ui/collapsible/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/semi-ui/collapsible/index.tsx b/packages/semi-ui/collapsible/index.tsx index c80f54ea67..f4a609e2e6 100644 --- a/packages/semi-ui/collapsible/index.tsx +++ b/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 { } componentDidUpdate(prevProps: Readonly, prevState: Readonly, 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); }