Skip to content

Commit

Permalink
Merge pull request #2631 from DouyinFE/fix/collapsible-compare
Browse files Browse the repository at this point in the history
fix: [Collapsible] remove useless isEqual compare in componentDidUpdate
  • Loading branch information
DaiQiangReal authored Dec 13, 2024
2 parents f41c493 + d71a328 commit 3579733
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/semi-ui/collapsible/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 3579733

Please sign in to comment.