ant-design / ant-design/pro-components

为什么 DrawerForm onFinish 后 会造成 ProFormDependency 重新渲染 或其 依赖项重新触发 onChange?

Open
#8,456 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
4.8k
Forks
1.4k
Avg merge
10h 44m
Merged PRs (30d)
3

Description

`
{(fvs) => {
const { data } = fvs.depFormItemName;
return (



);
}}
`
如上场景, depFormItemName 的值会携带 data 数据, data 改变时 内部组件 XXXTable 需要根据 data 重新整理数据并渲染, 但是触发 DrawerForm 的 onFinish 操作后会造成 ProFormDependency 重新渲染 并且传下来的 data 似乎也是全新的 会再次触发 useEffect, 导致 XXXTable 子组件用户已经填写的值被 按照 data 重新整理而重置, 虽然最终提交的值是正确的, 但是如果表单提交失败, 那用户已填写的值就会丢掉。 为什么会这样? 怎么避免这种情况

Contributor guide

Open the contributing guide

Research direction

Reproduce the shown DrawerForm, ProFormDependency, and XXXTable flow, then observe what changes after DrawerForm onFinish, including the dependency value identity and useEffect behavior. Confirm the cause and document a way to avoid resetting XXXTable's user-entered values when submission fails.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.