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

🐛[BUG]多步update例子中的UpdateForm可能丢失最后一步数据 #6220

Closed
carolwu-1206 opened this issue Mar 27, 2020 · 3 comments
Closed

Comments

@carolwu-1206
Copy link

carolwu-1206 commented Mar 27, 2020

🐛 bug 描述

  const handleNext = async () => {
    const fieldsValue = await form.validateFields();
    setFormVals({ ...formVals, ...fieldsValue });
    if (currentStep < 2) {
      forward();
    } else {
      handleUpdate(formVals);
    }
  };

这里setFormVals是异步的,因此在handleUpdate里拿到的不是最新数据。

📷 复现步骤

在service.ts的updateRule打印params内容

🏞 期望结果

💻 复现代码

© 版本信息

  • Ant Design Pro 版本: [e.g. 4.0.0]
  • umi 版本
  • 浏览器环境
  • 开发环境 [e.g. mac OS]

🚑 其他信息

@chenshuai2144
Copy link
Collaborator

来个 pr 修复一下?

@wxq851685279
Copy link

同样问题

@korenhe
Copy link

korenhe commented May 12, 2020

Here's a workaround:

-    handleUpdate(formVals);
+    handleUpdate({ ...formVals, ...fieldsValue });

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

No branches or pull requests

5 participants