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

preserve为false的FormItem销毁时会触发所有添加了shouldUpdate表单rerender #50283

Closed
JackWang032 opened this issue Aug 7, 2024 · 4 comments
Labels
improvement improve some features

Comments

@JackWang032
Copy link

Reproduction link

Edit on StackBlitz

Steps to reproduce

  1. 在B中随便输入点内容
  2. 在A中切换隐藏B
  3. 打开控制台,添加了shouldUpdate(永远返回false)的C表单render了一遍

What is expected?

C表单不进行render

What is actually happening?

C表单render了一遍

Environment Info
antd 5.20.0
React 18
System mac
Browser Chrome v116.0.5845.110

可能会引起性能问题
定位源码是remove时判断的是shouldUpdate而不是shouldUpdate && requireUpdate(shouldUpdate, xxx, xxx), 不知道是否是为了解决注释中提到的依赖传递的问题而这样写的。
image

Copy link

stackblitz bot commented Aug 7, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@crazyair
Copy link
Member

crazyair commented Aug 7, 2024

为什么 B 要有内容,才会触发 C render 呢?

@JackWang032
Copy link
Author

为什么 B 要有内容,才会触发 C render 呢?

注销effect里会判断当前值是否与inititalValue值相等才会触发remove类型的storeChange
image

@zombieJ
Copy link
Member

zombieJ commented Aug 7, 2024

是的,shouldUpdate 会重新跑一次防止 preserve 的负作用。我感觉也是可以跑一次 shouldUpdate 来看看要不要 rerender。

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

No branches or pull requests

3 participants