Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(field): remove useDeepCompareMemo which causing renderFormItem not updated #7887

Merged
merged 1 commit into from
Nov 13, 2023

Conversation

mjss
Copy link
Contributor

@mjss mjss commented Nov 9, 2023

Fix issue #7801.

Root cause

以7801中的例子来解释,form item按antd联动的方式定义

{
    title: "标签",
    dataIndex: "labels",
    valueType: "text",
    formItemProps: {
      dependencies: ["state"]
    },
    renderFormItem: (_, config, form) => {
      return form.getFieldValue("state") === "open" ? (
        <Input />
      ) : (
        <Select></Select>
      );
    }
  }

那么这个FormItem会在state值更改的时候重新渲染,但是重新渲染时props的内容用deep compare比较时并未改变,所以diff中的useDeepCompareMemo会导致本来可以渲染出的更新丢失掉。

2.6.20以及之前版本是正常的,是因为之前用的是 useMemouseMemo生效是因为rest在每次渲染的时候都会生成一个新的,应该是没有意义的,这里我直接去掉了。

Copy link

github-actions bot commented Nov 9, 2023

😭 Deploy PR Preview failed.

@chenshuai2144 chenshuai2144 merged commit d507222 into ant-design:master Nov 13, 2023
6 checks passed
@WuJiY
Copy link
Contributor

WuJiY commented Nov 14, 2023

是不是 #7761 ?终于fix 了吗😭

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants