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

condition/render can't work with dependencies in antd v5 #8

Open
andyyxw opened this issue Apr 28, 2024 · 0 comments
Open

condition/render can't work with dependencies in antd v5 #8

andyyxw opened this issue Apr 28, 2024 · 0 comments

Comments

@andyyxw
Copy link

andyyxw commented Apr 28, 2024

image
Field Condition示例中使用useWatch监听了favoriteFruit字段,导致整个form都跟随favoriteFruit在rerender。
antd v5中有dependencies / shouldUpdate可以使某个表单项只依赖部分表单项,可减少render次数以提高性能,但是发现这种方式目前NiceForm并不支持:

{
  key: 'otherFruit',
  label: 'Other',
  dependencies: ['favoriteFruit'],
  condition: () => NiceForm.getFieldValue('favoriteFruit', meta, form) === 'Other',
}

源码中condition逻辑是在FormField中,实际上只会在整个form render 时执行:
image
可以将condition / render逻辑转移到adapter中的renderField,但这样对 adapter 是 breaking change
image

@andyyxw andyyxw changed the title condition/render can't work with dependencies in antd condition/render can't work with dependencies in antd v5 Apr 28, 2024
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

No branches or pull requests

1 participant