We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
在 ProForm 中使用 Form.useWatch 监听数组类型的字段时,当表单被重置(reset)后,数组类型的值会被错误地转换成对象格式。
例如:原本的 [{}] 会变成 {0: {}},这导致后续的数组操作出现异常。
[{}]
{0: {}}
表单重置后,数组字段应该保持数组格式 [{}],而不是变成对象格式 {0: {}}。
demo codesandbox
问题似乎出在 BaseForm.tsx 中的 transformKey 函数处理过程。在表单重置时,通过 onValuesChange 触发的值转换过程中,数组被错误地转换成了对象格式。
相关源码: https://github.com/ant-design/pro-components/blob/master/packages/form/src/BaseForm/BaseForm.tsx#L809-L814 https://github.com/ant-design/pro-components/blob/master/packages/utils/src/transformKeySubmitValue/index.ts
@chenshuai2144 @Wxh16144
The text was updated successfully, but these errors were encountered:
No branches or pull requests
🐛 bug 描述
在 ProForm 中使用 Form.useWatch 监听数组类型的字段时,当表单被重置(reset)后,数组类型的值会被错误地转换成对象格式。
例如:原本的
[{}]
会变成{0: {}}
,这导致后续的数组操作出现异常。📷 复现步骤
🏞 期望结果
表单重置后,数组字段应该保持数组格式
[{}]
,而不是变成对象格式{0: {}}
。💻 复现代码
demo codesandbox
© 版本信息
🚑 其他信息
问题似乎出在 BaseForm.tsx 中的 transformKey 函数处理过程。在表单重置时,通过 onValuesChange 触发的值转换过程中,数组被错误地转换成了对象格式。
相关源码:
https://github.com/ant-design/pro-components/blob/master/packages/form/src/BaseForm/BaseForm.tsx#L809-L814
https://github.com/ant-design/pro-components/blob/master/packages/utils/src/transformKeySubmitValue/index.ts
@chenshuai2144 @Wxh16144
The text was updated successfully, but these errors were encountered: