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

Form.Item 里面的 shouldUpdate 方法没有触发 #34500

Closed
1 task done
cielu opened this issue Mar 15, 2022 · 3 comments
Closed
1 task done

Form.Item 里面的 shouldUpdate 方法没有触发 #34500

cielu opened this issue Mar 15, 2022 · 3 comments
Labels
🤔 Need Reproduce We cannot reproduce your problem

Comments

@cielu
Copy link

cielu commented Mar 15, 2022

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

https://github.com/ant-design/ant-design

Steps to reproduce

<Form.Item
  noStyle
  shouldUpdate={(prevValues, currentValues) => {
    console.log("dsafwjdoisafjodisajf")
    return prevValues.failedRetry !== currentValues.failedRetry
  }}
>

就是这玩意,里面的 console.log 都不执行。。之前好像是正常的

What is expected?

正常执行 console.log

What is actually happening?

没有执行

Environment Info
antd 4.19.2
React 17.0.2
System mac os 12.2.1
Browser google 99.04844.51
@afc163 afc163 added the 🤔 Need Reproduce We cannot reproduce your problem label Mar 15, 2022
@github-actions
Copy link
Contributor

Hello @cielu. Please provide a online reproduction by forking this link https://u.ant.design/codesandbox-repro or a minimal GitHub repository. Issues labeled by Need Reproduce will be closed if no activities in 3 days.

你好 @cielu, 我们需要你提供一个在线的重现实例以便于我们帮你排查问题。你可以通过点击 此处 创建一个 codesandbox 或者提供一个最小化的 GitHub 仓库。3 天内未跟进此 issue 将会被自动关闭。

@cielu
Copy link
Author

cielu commented Mar 15, 2022

你让我提供代码,我提供不出来,我用的 ant-design-pro 搞的,我估摸着和他有关系,让我录个视频还可以,搞代码,我搞到那个沙盒里面都不重现。。。用的我真是无话可说

@yyxTheOracle
Copy link
Contributor

yyxTheOracle commented Jan 21, 2023

你让我提供代码,我提供不出来,我用的 ant-design-pro 搞的,我估摸着和他有关系,让我录个视频还可以,搞代码,我搞到那个沙盒里面都不重现。。。用的我真是无话可说

你是不是 Form.Item 的标签体里没写成函数的形式啊👀像下面这样写,shouldUpdate 是不会触发的:

<Form.Item
 noStyle
 shouldUpdate={(prev, current) => {
   console.log('test');
   return prev.xxx !== currentValues.xxx;
 }
}>
   <Input />
</Form.Item>

标签体里写成函数的形式才可以:

<Form.Item
 noStyle
 shouldUpdate={(prev, current) => {
   console.log('test');
   return prev.xxx !== currentValues.xxx;
 }
}>
   {() => <Input />}
 </Form.Item>

@ghost ghost mentioned this issue Aug 31, 2023
20 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤔 Need Reproduce We cannot reproduce your problem
Projects
None yet
Development

No branches or pull requests

3 participants